From e7a7c0c578850f42726911e66efaec93e591dc6b Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Mar 2026 14:05:05 +0100 Subject: [PATCH] style(command/moderation): adding the format_sanction_reason function --- src/commands/moderation/kick.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/commands/moderation/kick.rs b/src/commands/moderation/kick.rs index 3062144..efc8942 100644 --- a/src/commands/moderation/kick.rs +++ b/src/commands/moderation/kick.rs @@ -1,5 +1,6 @@ use crate::commands::{CommandCategory, CommandEntry, SlashCommand}; use crate::config::EmojiConfig; +use crate::utils::format::format_sanction_reason; use serenity::all::{ CommandInteraction, CommandOptionType, Context, CreateCommand, CreateCommandOption, CreateInteractionResponse, CreateInteractionResponseMessage, EditInteractionResponse, GetMessages, Guild, GuildId, InteractionContext, Member, Message, MessageId, Permissions, Role, User, UserId @@ -10,13 +11,6 @@ use anyhow::Result; pub struct Kick; -fn format_reason(reason: Option<&str>, executor: &str) -> String { - match reason { - Some(s) => format!("[TTY kick] {} by {}", s, executor), - None => format!("[TTY kick] by {}", executor) - } -} - #[serenity::async_trait] impl SlashCommand for Kick { fn name(&self) -> &'static str { @@ -68,7 +62,7 @@ impl SlashCommand for Kick { .ok_or_else(|| anyhow::anyhow!("Utilisateur introuvable"))? .clone(); let reason_provided: Option<&str> = command.data.options.iter().find(|opt | opt.kind() == CommandOptionType::String).and_then(|opt| opt.value.as_str()); - let reason_formatted: String = format_reason(reason_provided, &command.user.name); + let reason_formatted: String = format_sanction_reason("kick", reason_provided, &command.user.name); let guild_id: GuildId = command.guild_id.ok_or(anyhow::anyhow!("Kick command executed in DM"))?; let guild: Guild = ctx.cache.guild(guild_id)