diff --git a/src/commands/automation/autopublish.rs b/src/commands/automation/autopublish.rs index 77b82c3..3a4bf40 100644 --- a/src/commands/automation/autopublish.rs +++ b/src/commands/automation/autopublish.rs @@ -78,7 +78,8 @@ pub async fn handle_autopublishon(ctx: &Context, msg: &Message, args: &[&str]) { .and_then(|value| parse_channel_id(value)) .unwrap_or(msg.channel_id); - let result = db::add_autopublish_channel(&pool, bot_id, guild_id_i64, channel_id.get() as i64).await; + let result = + db::add_autopublish_channel(&pool, bot_id, guild_id_i64, channel_id.get() as i64).await; if result.is_err() { send_embed( diff --git a/src/commands/automation/autopublishoff.rs b/src/commands/automation/autopublishoff.rs index 911d4a7..fe22027 100644 --- a/src/commands/automation/autopublishoff.rs +++ b/src/commands/automation/autopublishoff.rs @@ -15,7 +15,11 @@ impl crate::commands::command_contract::CommandSpec for AutopublishoffCommand { category: "automation", params: "[#canal]", description: "Desactive la publication automatique des annonces sur un salon.", - examples: &["+autopublishoff", "+autopublishoff #annonces", "+help autopublishoff"], + examples: &[ + "+autopublishoff", + "+autopublishoff #annonces", + "+help autopublishoff", + ], default_aliases: &["apboff"], allow_in_dm: false, default_permission: 5, diff --git a/src/commands/automation/autopublishon.rs b/src/commands/automation/autopublishon.rs index a584bb9..165b6e0 100644 --- a/src/commands/automation/autopublishon.rs +++ b/src/commands/automation/autopublishon.rs @@ -15,7 +15,11 @@ impl crate::commands::command_contract::CommandSpec for AutopublishonCommand { category: "automation", params: "[#canal]", description: "Active la publication automatique des annonces sur un salon.", - examples: &["+autopublishon", "+autopublishon #annonces", "+help autopublishon"], + examples: &[ + "+autopublishon", + "+autopublishon #annonces", + "+help autopublishon", + ], default_aliases: &["apbon"], allow_in_dm: false, default_permission: 5, diff --git a/src/commands/automation/piconly.rs b/src/commands/automation/piconly.rs index 85bd22e..81cd7e5 100644 --- a/src/commands/automation/piconly.rs +++ b/src/commands/automation/piconly.rs @@ -164,7 +164,8 @@ pub async fn handle_piconlyadd(ctx: &Context, msg: &Message, args: &[&str]) { .and_then(|raw| parse_channel_id(raw)) .unwrap_or(msg.channel_id); - let result = db::add_piconly_channel(&pool, bot_id, guild_id_i64, channel_id.get() as i64).await; + let result = + db::add_piconly_channel(&pool, bot_id, guild_id_i64, channel_id.get() as i64).await; if result.is_err() { send_embed( @@ -210,7 +211,8 @@ pub async fn handle_piconlydel(ctx: &Context, msg: &Message, args: &[&str]) { .and_then(|raw| parse_channel_id(raw)) .unwrap_or(msg.channel_id); - let result = db::remove_piconly_channel(&pool, bot_id, guild_id_i64, channel_id.get() as i64).await; + let result = + db::remove_piconly_channel(&pool, bot_id, guild_id_i64, channel_id.get() as i64).await; if result.is_err() { send_embed( diff --git a/src/commands/botconfig/setperm.rs b/src/commands/botconfig/setperm.rs index a1e04b1..fa0fb2b 100644 --- a/src/commands/botconfig/setperm.rs +++ b/src/commands/botconfig/setperm.rs @@ -15,7 +15,11 @@ impl crate::commands::command_contract::CommandSpec for SetpermCommand { category: "botconfig", params: " ", description: "Attribue un niveau ACL ou un acces commande a un role ou membre.", - examples: &["+setperm 6 @Moderateur", "+setperm mute @Role", "+help setperm"], + examples: &[ + "+setperm 6 @Moderateur", + "+setperm mute @Role", + "+help setperm", + ], default_aliases: &["stp"], allow_in_dm: false, default_permission: 9, diff --git a/src/commands/config/leavesettings.rs b/src/commands/config/leavesettings.rs index e991314..6e05b8f 100644 --- a/src/commands/config/leavesettings.rs +++ b/src/commands/config/leavesettings.rs @@ -143,10 +143,7 @@ impl crate::commands::command_contract::CommandSpec for LeaveSettingsCommand { category: "config", params: "[on/off] [salon] [message]", description: "Configure les actions a executer quand un membre quitte le serveur.", - examples: &[ - "+leavesettings", - "+leavesettings on #logs {user} a quitte", - ], + examples: &["+leavesettings", "+leavesettings on #logs {user} a quitte"], default_aliases: &["lset"], allow_in_dm: false, default_permission: 5, diff --git a/src/commands/config/setboostembed.rs b/src/commands/config/setboostembed.rs index 8101835..022fd4e 100644 --- a/src/commands/config/setboostembed.rs +++ b/src/commands/config/setboostembed.rs @@ -103,10 +103,7 @@ impl crate::commands::command_contract::CommandSpec for SetBoostembedCommand { category: "config", params: " ", description: "Configure le titre, la description et la couleur de l embed boost.", - examples: &[ - "+setboostembed title Merci", - "+setboostembed color #FF66CC", - ], + examples: &["+setboostembed title Merci", "+setboostembed color #FF66CC"], default_aliases: &["sboostembed"], allow_in_dm: false, default_permission: 6, diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 27b47a7..f5cb2ec 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -2,13 +2,14 @@ use crate::commands::command_contract::{CommandMetadata, CommandSpec}; #[path = "roles/addrole.rs"] pub mod addrole; +#[path = "../utils/admin_common.rs"] pub mod admin_common; +#[path = "../utils/admin_service.rs"] pub mod admin_service; +#[path = "../utils/advanced_tools.rs"] pub mod advanced_tools; #[path = "perms/alias.rs"] pub mod alias; -#[path = "perms/unalias.rs"] -pub mod unalias; #[path = "info/alladmins.rs"] pub mod alladmins; #[path = "info/allbots.rs"] @@ -29,6 +30,7 @@ pub mod antispam; pub mod autobackup; #[path = "config/autoconfiglog.rs"] pub mod autoconfiglog; +#[path = "../utils/automod_service.rs"] pub mod automod_service; #[path = "automation/autopublish.rs"] pub mod autopublish; @@ -60,7 +62,9 @@ pub mod boosters; pub mod boostlog; #[path = "owner/botadmins.rs"] pub mod botadmins; +#[path = "../utils/botconfig_common.rs"] pub mod botconfig_common; +#[path = "../utils/botconfig_service.rs"] pub mod botconfig_service; #[path = "channel/bringall.rs"] pub mod bringall; @@ -70,10 +74,10 @@ pub mod button; pub mod calc; #[path = "botconfig/change.rs"] pub mod change; -#[path = "botconfig/changereset.rs"] -pub mod changereset; #[path = "botconfig/changeall.rs"] pub mod changeall; +#[path = "botconfig/changereset.rs"] +pub mod changereset; #[path = "info/channel.rs"] pub mod channel; #[path = "fun/choose.rs"] @@ -102,18 +106,20 @@ pub mod clear_sanctions; pub mod close; #[path = "mod/cmute.rs"] pub mod cmute; +#[path = "../utils/command_contract.rs"] pub mod command_contract; +#[path = "../utils/common.rs"] pub mod common; #[path = "botconfig/compet.rs"] pub mod compet; #[path = "automation/create.rs"] pub mod create; -#[path = "perms/del.rs"] +#[path = "../utils/del.rs"] pub mod del; -#[path = "perms/delperm.rs"] -pub mod delperm; #[path = "mod/delsanction.rs"] pub mod del_sanction; +#[path = "perms/delperm.rs"] +pub mod delperm; #[path = "roles/delrole.rs"] pub mod delrole; #[path = "roles/derank.rs"] @@ -164,7 +170,9 @@ pub mod loading; pub mod lock; #[path = "channel/lockall.rs"] pub mod lockall; +#[path = "../utils/logs_command_helpers.rs"] pub mod logs_command_helpers; +#[path = "../utils/logs_service.rs"] pub mod logs_service; #[path = "botconfig/mainprefix.rs"] pub mod mainprefix; @@ -174,8 +182,11 @@ pub mod massiverole; pub mod member; #[path = "config/messagelog.rs"] pub mod messagelog; +#[path = "../utils/moderation_channel_helpers.rs"] pub mod moderation_channel_helpers; +#[path = "../utils/moderation_sanction_helpers.rs"] pub mod moderation_sanction_helpers; +#[path = "../utils/moderation_tools.rs"] pub mod moderation_tools; #[path = "config/modlog.rs"] pub mod modlog; @@ -209,7 +220,9 @@ pub mod online; pub mod owner; #[path = "perms/perms.rs"] pub mod perms; +#[path = "../utils/perms_helpers.rs"] pub mod perms_helpers; +#[path = "../utils/perms_service.rs"] pub mod perms_service; #[path = "info/pic.rs"] pub mod pic; @@ -261,16 +274,22 @@ pub mod sanctions; pub mod say; #[path = "info/serverbanner.rs"] pub mod serverbanner; +#[path = "info/serverinfo.rs"] +pub mod serverinfo; #[path = "info/serverlist.rs"] pub mod serverlist; #[path = "info/serverpic.rs"] pub mod serverpic; -#[path = "info/servertarget.rs"] +#[path = "../utils/servertarget.rs"] pub mod servertarget; -#[path = "info/serverinfo.rs"] -pub mod serverinfo; -#[path = "botconfig/set.rs"] +#[path = "../utils/set.rs"] pub mod set; +#[path = "config/setboostembed.rs"] +pub mod set_boostembed; +#[path = "config/setmodlogs.rs"] +pub mod set_modlogs; +#[path = "mod/setmuterole.rs"] +pub mod set_muterole; #[path = "botconfig/setbanner.rs"] pub mod setbanner; #[path = "botconfig/setname.rs"] @@ -281,12 +300,6 @@ pub mod setperm; pub mod setpic; #[path = "botconfig/setprofil.rs"] pub mod setprofil; -#[path = "config/setboostembed.rs"] -pub mod set_boostembed; -#[path = "config/setmodlogs.rs"] -pub mod set_modlogs; -#[path = "mod/setmuterole.rs"] -pub mod set_muterole; #[path = "botconfig/shadowbot.rs"] pub mod shadowbot; #[path = "info/showpics.rs"] @@ -329,6 +342,8 @@ pub mod ticket_member; pub mod tickets; #[path = "mod/timeout.rs"] pub mod timeout; +#[path = "perms/unalias.rs"] +pub mod unalias; #[path = "mod/unban.rs"] pub mod unban; #[path = "mod/unbanall.rs"] @@ -556,12 +571,10 @@ pub fn command_metadata_by_key(key: &str) -> Option { let normalized = key.to_lowercase(); let compact = normalized.replace('_', ""); - all_command_metadata() - .into_iter() - .find(|meta| { - meta.name.eq_ignore_ascii_case(&normalized) - || meta.name.replace('_', "").eq_ignore_ascii_case(&compact) - }) + all_command_metadata().into_iter().find(|meta| { + meta.name.eq_ignore_ascii_case(&normalized) + || meta.name.replace('_', "").eq_ignore_ascii_case(&compact) + }) } pub fn resolve_default_alias(alias: &str) -> Option<&'static str> { diff --git a/src/commands/perms/alias.rs b/src/commands/perms/alias.rs index d9d08b3..2b0ea98 100644 --- a/src/commands/perms/alias.rs +++ b/src/commands/perms/alias.rs @@ -45,7 +45,9 @@ pub async fn handle_alias(ctx: &Context, msg: &Message, args: &[&str]) { } let command = args[0].trim_start_matches('+').to_lowercase(); - let is_known = all_command_keys().iter().any(|candidate| candidate == &command) + let is_known = all_command_keys() + .iter() + .any(|candidate| candidate == &command) || crate::commands::command_metadata_by_key(&command).is_some(); if !is_known { let embed = serenity::builder::CreateEmbed::new() diff --git a/src/commands/perms/help.rs b/src/commands/perms/help.rs index eb8c060..5388242 100644 --- a/src/commands/perms/help.rs +++ b/src/commands/perms/help.rs @@ -135,28 +135,10 @@ fn help_page_for_command( "modlog" | "messagelog" | "voicelog" | "boostlog" | "rolelog" | "raidlog" | "autoconfiglog" | "nolog" | "joinsettings" | "boostembed" | "setmodlogs" | "setboostembed" | "leavesettings" | "viewlogs" => "logs", - "warn" - | "mute" - | "tempmute" - | "unmute" - | "cmute" - | "tempcmute" - | "uncmute" - | "mutelist" - | "unmuteall" - | "kick" - | "ban" - | "tempban" - | "unban" - | "banlist" - | "unbanall" - | "sanctions" - | "delsanction" - | "clearsanctions" - | "clearallsanctions" - | "cleanup" - | "renew" - | "clearmessages" => "moderation", + "warn" | "mute" | "tempmute" | "unmute" | "cmute" | "tempcmute" | "uncmute" + | "mutelist" | "unmuteall" | "kick" | "ban" | "tempban" | "unban" | "banlist" + | "unbanall" | "sanctions" | "delsanction" | "clearsanctions" | "clearallsanctions" + | "cleanup" | "renew" | "clearmessages" => "moderation", "addrole" | "delrole" | "derank" | "massiverole" | "unmassiverole" | "temprole" | "untemprole" | "sync" => "roles", "lock" | "unlock" | "lockall" | "unlockall" | "hide" | "unhide" | "hideall" @@ -164,19 +146,13 @@ fn help_page_for_command( "giveaway" | "end" | "reroll" | "choose" | "calc" | "emoji" | "embed" | "say" | "create" | "newsticker" | "button" | "autoreact" | "snipe" | "loading" | "backup" | "autobackup" => "outils", - "shadowbot" | "setname" | "setpic" | "setbanner" | "setprofil" | "setperm" - | "theme" | "playto" | "listen" | "watch" | "compet" | "stream" - | "removeactivity" | "online" | "idle" | "dnd" | "invisible" | "change" - | "changereset" | "changeall" => { - "bot" - } - "owner" | "unowner" | "clearowners" | "bl" | "unbl" | "blinfo" | "clearbl" - | "allbots" | "alladmins" | "botadmins" | "mainprefix" | "prefix" | "mp" - | "mpsettings" | "mpsent" | "mpdelete" | "invite" | "leave" | "discussion" => { - "administration" - } - "perms" | "delperm" | "clearperms" | "allperms" | "alias" | "help" - | "helpsetting" => { + "shadowbot" | "setname" | "setpic" | "setbanner" | "setprofil" | "setperm" | "theme" + | "playto" | "listen" | "watch" | "compet" | "stream" | "removeactivity" | "online" + | "idle" | "dnd" | "invisible" | "change" | "changereset" | "changeall" => "bot", + "owner" | "unowner" | "clearowners" | "bl" | "unbl" | "blinfo" | "clearbl" | "allbots" + | "alladmins" | "botadmins" | "mainprefix" | "prefix" | "mp" | "mpsettings" | "mpsent" + | "mpdelete" | "invite" | "leave" | "discussion" => "administration", + "perms" | "delperm" | "clearperms" | "allperms" | "alias" | "help" | "helpsetting" => { "permissions" } _ => match meta.category { @@ -410,9 +386,7 @@ fn help_lookup_to_key(input: &str) -> Option<&'static str> { "newsticker" => Some("newsticker"), "piconly" => Some("piconly"), "piconly add" | "piconlyadd" => Some("piconlyadd"), - "piconly del" | "piconly remove" | "piconly delete" | "piconlydel" => { - Some("piconlydel") - } + "piconly del" | "piconly remove" | "piconly delete" | "piconlydel" => Some("piconlydel"), "massiverole" => Some("massiverole"), "unmassiverole" => Some("unmassiverole"), "noderank" => Some("noderank"), diff --git a/src/events/message_event.rs b/src/events/message_event.rs index 47cf415..81bc4f3 100644 --- a/src/events/message_event.rs +++ b/src/events/message_event.rs @@ -9,22 +9,21 @@ use crate::commands::{ addrole, alias, ancien, antilink, antimassmention, antiraideautoconfig, antispam, autobackup, autoconfiglog, autopublish, autopublishoff, autopublishon, autoreact, backup, badwords, ban, banlist, banner, bl, blinfo, boostembed, boosters, boostlog, bringall, button, calc, change, - changeall, changereset, - channel, choose, claim, cleanup, clear_all_sanctions, clear_badwords, clear_bl, clear_limit, - clear_messages, clear_owners, clear_perms, clear_sanctions, close, cmute, compet, create, - del_sanction, delperm, delrole, derank, discussion, dnd, embed, emoji, end, endgiveaway, - giveaway, help, helpsetting, hide, hideall, idle, invisible, invite, join, kick, leave, - leave_settings, link, listen, loading, lock, lockall, mainprefix, massiverole, member, - messagelog, modlog, mp, mpdelete, mpsent, mpsettings, mute, mutelist, muterole, newsticker, - noderank, noderankadd, noderankdel, nolog, online, owner, perms, pic, piconly, piconlyadd, - piconlydel, ping, playto, prefix, public, punish, punishadd, punishdel, punishsetup, - raidlog, rename, renew, reroll, resetantiraide, role, rolelog, rolemembers, rolemenu, - sanctions, say, serverbanner, serverinfo, serverlist, serverpic, set_boostembed, - set_modlogs, set_muterole, setbanner, setname, setperm, setpic, setprofil, shadowbot, - showpics, slowmode, snipe, spam, stream, strikes, suggestion, suggestionsettings, sync, - tempban, tempcmute, tempmute, temprole, tempvoc, tempvoc_cmd, theme, ticket, ticket_member, - tickets, timeout, unban, unbanall, unbl, uncmute, unhide, unhideall, unlock, unlockall, - unalias, unmassiverole, unmute, unmuteall, unowner, untemprole, user, viewlogs, vocinfo, voicekick, + changeall, changereset, channel, choose, claim, cleanup, clear_all_sanctions, clear_badwords, + clear_bl, clear_limit, clear_messages, clear_owners, clear_perms, clear_sanctions, close, + cmute, compet, create, del_sanction, delperm, delrole, derank, discussion, dnd, embed, emoji, + end, endgiveaway, giveaway, help, helpsetting, hide, hideall, idle, invisible, invite, join, + kick, leave, leave_settings, link, listen, loading, lock, lockall, mainprefix, massiverole, + member, messagelog, modlog, mp, mpdelete, mpsent, mpsettings, mute, mutelist, muterole, + newsticker, noderank, noderankadd, noderankdel, nolog, online, owner, perms, pic, piconly, + piconlyadd, piconlydel, ping, playto, prefix, public, punish, punishadd, punishdel, + punishsetup, raidlog, rename, renew, reroll, resetantiraide, role, rolelog, rolemembers, + rolemenu, sanctions, say, serverbanner, serverinfo, serverlist, serverpic, set_boostembed, + set_modlogs, set_muterole, setbanner, setname, setperm, setpic, setprofil, shadowbot, showpics, + slowmode, snipe, spam, stream, strikes, suggestion, suggestionsettings, sync, tempban, + tempcmute, tempmute, temprole, tempvoc, tempvoc_cmd, theme, ticket, ticket_member, tickets, + timeout, unalias, unban, unbanall, unbl, uncmute, unhide, unhideall, unlock, unlockall, + unmassiverole, unmute, unmuteall, unowner, untemprole, user, viewlogs, vocinfo, voicekick, voicelog, voicemove, warn, watch, }; use crate::commands::{alladmins, allbots, allperms, botadmins}; diff --git a/src/events/mod.rs b/src/events/mod.rs index a0c06a3..05932f0 100644 --- a/src/events/mod.rs +++ b/src/events/mod.rs @@ -1,6 +1,7 @@ pub mod channel_event; pub mod guild_create_event; pub mod guild_member_event; +#[path = "../utils/events_handler.rs"] pub mod handler; pub mod interaction_create_event; pub mod message_delete_event; diff --git a/src/commands/perms/del.rs b/src/utils/del.rs similarity index 99% rename from src/commands/perms/del.rs rename to src/utils/del.rs index edc9143..e4aef84 100644 --- a/src/commands/perms/del.rs +++ b/src/utils/del.rs @@ -49,4 +49,3 @@ pub async fn handle_del(ctx: &Context, msg: &Message, args: &[&str]) { .color(0x57F287); send_embed(ctx, msg, embed).await; } - diff --git a/src/utils/perms_helpers.rs b/src/utils/perms_helpers.rs index c164b06..4df4b5d 100644 --- a/src/utils/perms_helpers.rs +++ b/src/utils/perms_helpers.rs @@ -34,10 +34,7 @@ pub fn parse_user_or_role(input: &str) -> Option<(&'static str, u64)> { pub fn normalize_command_name(input: &str) -> String { let normalized = input.trim_start_matches('+').to_lowercase(); - let underscored = normalized - .split_whitespace() - .collect::>() - .join("_"); + let underscored = normalized.split_whitespace().collect::>().join("_"); let compact = underscored.replace('_', ""); let known = crate::permissions::all_command_keys(); diff --git a/src/commands/info/servertarget.rs b/src/utils/servertarget.rs similarity index 100% rename from src/commands/info/servertarget.rs rename to src/utils/servertarget.rs diff --git a/src/commands/botconfig/set.rs b/src/utils/set.rs similarity index 99% rename from src/commands/botconfig/set.rs rename to src/utils/set.rs index dfd5ed3..f641a1f 100644 --- a/src/commands/botconfig/set.rs +++ b/src/utils/set.rs @@ -286,4 +286,3 @@ pub async fn handle_setprofil(ctx: &Context, msg: &Message, args: &[&str]) { }; send_embed(ctx, msg, embed).await; } -