mirror of
https://github.com/arthur-pbty/shadowbot.git
synced 2026-06-10 19:04:31 +02:00
Refactor code for improved readability and consistency across various command files
- Adjusted formatting and indentation in `rename.rs`, `suggestion.rs`, `tempvoc.rs`, `ticket.rs`, `ticket_member.rs`, and `tickets.rs` for better clarity. - Consolidated `if` statements and method calls for cleaner code in `suggestion.rs`, `tempvoc.rs`, and `ticket.rs`. - Updated the `LOGS_PER_PAGE` constant in `viewlogs.rs` to increase the number of logs displayed per page. - Removed unused `handle_boostembed` function from `logs_service.rs`. - Added new modules in `mod.rs` for better organization of command files. - Enhanced the `handle_show_pics` function in `showpics.rs` for improved member filtering. - Updated the `handle_message` function in `message_event.rs` to streamline command handling.
This commit is contained in:
@@ -569,102 +569,6 @@ async fn run_join_leave_action(ctx: &Context, guild_id: GuildId, kind: &str, use
|
||||
let _ = channel_id.say(&ctx.http, content).await;
|
||||
}
|
||||
|
||||
pub async fn handle_boostembed(ctx: &Context, msg: &Message, args: &[&str]) {
|
||||
let Some(guild_id) = msg.guild_id else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(pool) = pool(ctx).await else {
|
||||
return;
|
||||
};
|
||||
let bot_id = ctx.cache.current_user().id;
|
||||
|
||||
if let Some(action) = args.first().map(|v| v.to_lowercase()) {
|
||||
match action.as_str() {
|
||||
"on" | "off" => {
|
||||
let enabled = action == "on";
|
||||
let _ = sqlx::query(
|
||||
r#"
|
||||
INSERT INTO bot_boost_embed (bot_id, guild_id, enabled)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (bot_id, guild_id)
|
||||
DO UPDATE SET enabled = EXCLUDED.enabled, updated_at = NOW();
|
||||
"#,
|
||||
)
|
||||
.bind(bot_id.get() as i64)
|
||||
.bind(guild_id.get() as i64)
|
||||
.bind(enabled)
|
||||
.execute(&pool)
|
||||
.await;
|
||||
|
||||
send_embed(
|
||||
ctx,
|
||||
msg,
|
||||
CreateEmbed::new()
|
||||
.title("BoostEmbed")
|
||||
.description(if enabled { "Activé" } else { "Désactivé" })
|
||||
.color(theme_color(ctx).await),
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
"test" => {
|
||||
send_boost_embed(ctx, guild_id, &msg.author).await;
|
||||
send_embed(
|
||||
ctx,
|
||||
msg,
|
||||
CreateEmbed::new()
|
||||
.title("BoostEmbed")
|
||||
.description("Test envoyé.")
|
||||
.color(theme_color(ctx).await),
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
let row = sqlx::query_as::<_, (bool, Option<String>, Option<String>, Option<i32>)>(
|
||||
r#"
|
||||
SELECT enabled, title, description, color
|
||||
FROM bot_boost_embed
|
||||
WHERE bot_id = $1 AND guild_id = $2
|
||||
LIMIT 1;
|
||||
"#,
|
||||
)
|
||||
.bind(bot_id.get() as i64)
|
||||
.bind(guild_id.get() as i64)
|
||||
.fetch_optional(&pool)
|
||||
.await
|
||||
.ok()
|
||||
.flatten();
|
||||
|
||||
let desc = if let Some((enabled, title, description, color)) = row {
|
||||
format!(
|
||||
"État: {}\nTitle: {}\nDescription: {}\nColor: {}",
|
||||
if enabled { "on" } else { "off" },
|
||||
title.unwrap_or_else(|| "(défaut)".to_string()),
|
||||
description.unwrap_or_else(|| "(défaut)".to_string()),
|
||||
color
|
||||
.map(|v| format!("#{:06X}", v.max(0) as u32))
|
||||
.unwrap_or_else(|| "(thème)".to_string())
|
||||
)
|
||||
} else {
|
||||
"Aucun réglage boost embed.".to_string()
|
||||
};
|
||||
|
||||
send_embed(
|
||||
ctx,
|
||||
msg,
|
||||
CreateEmbed::new()
|
||||
.title("BoostEmbed")
|
||||
.description(desc)
|
||||
.color(theme_color(ctx).await),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
pub async fn handle_set_boostembed(ctx: &Context, msg: &Message, args: &[&str]) {
|
||||
let Some(guild_id) = msg.guild_id else {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user