mirror of
https://github.com/arthur-pbty/shadowbot.git
synced 2026-06-21 13:55:18 +02:00
feat(moderation): add commands for anti-raid reset, mute role setting, spam overrides, strikes management, and timeout toggling
- Implemented `resetantiraide` command to reset anti-raid protections to default settings. - Added `set_muterole` command to define the mute role when timeout mode is disabled. - Created `spam` command to manage spam moderation channel overrides (allow, deny, reset). - Developed `strikes` command to display and modify strike rules for various triggers. - Introduced `timeout` command to toggle the use of Discord timeout for mutes. feat(outils): add piconly command to manage photo-only channels - Implemented `piconly` command to define or remove channels where only photos can be sent. - Added functionality to enforce photo-only rules in designated channels. feat(roles): add ancien and noderank commands for role management - Created `ancien` command to set up a role for members after a specified delay. - Implemented `noderank` command to manage protected roles that are not removed by derank actions.
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
use serenity::builder::CreateEmbed;
|
||||
use serenity::model::prelude::*;
|
||||
use serenity::prelude::*;
|
||||
|
||||
use crate::commands::automod_service::pool;
|
||||
use crate::commands::common::{parse_channel_id, send_embed};
|
||||
use crate::db;
|
||||
|
||||
pub async fn handle_spam_override(ctx: &Context, msg: &Message, args: &[&str]) {
|
||||
let Some(guild_id) = msg.guild_id else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(action) = args.first() else {
|
||||
send_embed(
|
||||
ctx,
|
||||
msg,
|
||||
CreateEmbed::new()
|
||||
.title("Spam")
|
||||
.description("Usage: +spam <allow/deny/reset> [#salon]")
|
||||
.color(0xED4245),
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
};
|
||||
|
||||
let channel_id = args
|
||||
.get(1)
|
||||
.and_then(|raw| parse_channel_id(raw))
|
||||
.unwrap_or(msg.channel_id);
|
||||
|
||||
let Some(pool) = pool(ctx).await else {
|
||||
return;
|
||||
};
|
||||
|
||||
let bot_id = ctx.cache.current_user().id.get() as i64;
|
||||
let guild_id_raw = guild_id.get() as i64;
|
||||
let channel_id_raw = channel_id.get() as i64;
|
||||
|
||||
let description = if action.eq_ignore_ascii_case("allow") {
|
||||
let _ = db::set_moderation_channel_override(
|
||||
&pool,
|
||||
bot_id,
|
||||
guild_id_raw,
|
||||
channel_id_raw,
|
||||
"spam",
|
||||
"allow",
|
||||
)
|
||||
.await;
|
||||
format!("Antispam desactive dans <#{}>.", channel_id.get())
|
||||
} else if action.eq_ignore_ascii_case("deny") {
|
||||
let _ = db::set_moderation_channel_override(
|
||||
&pool,
|
||||
bot_id,
|
||||
guild_id_raw,
|
||||
channel_id_raw,
|
||||
"spam",
|
||||
"deny",
|
||||
)
|
||||
.await;
|
||||
format!("Antispam force dans <#{}>.", channel_id.get())
|
||||
} else if action.eq_ignore_ascii_case("reset") {
|
||||
let _ = db::remove_moderation_channel_override(
|
||||
&pool,
|
||||
bot_id,
|
||||
guild_id_raw,
|
||||
channel_id_raw,
|
||||
"spam",
|
||||
)
|
||||
.await;
|
||||
format!("Override antispam supprime dans <#{}>.", channel_id.get())
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
||||
send_embed(
|
||||
ctx,
|
||||
msg,
|
||||
CreateEmbed::new()
|
||||
.title("Spam Override")
|
||||
.description(description)
|
||||
.color(0x57F287),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
pub struct SpamCommand;
|
||||
pub static COMMAND_DESCRIPTOR: SpamCommand = SpamCommand;
|
||||
|
||||
impl crate::commands::command_contract::CommandSpec for SpamCommand {
|
||||
fn metadata(&self) -> crate::commands::command_contract::CommandMetadata {
|
||||
crate::commands::command_contract::CommandMetadata {
|
||||
name: "spam",
|
||||
category: "moderation",
|
||||
params: "<allow/deny/reset> [#salon]",
|
||||
description: "Definit l override antispam pour un salon (allow, deny, reset).",
|
||||
examples: &["+spam allow #general", "+spam deny #flood", "+spam reset"],
|
||||
default_aliases: &["spamch"],
|
||||
allow_in_dm: false,
|
||||
default_permission: 8,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user