Files
shadowbot/src/commands/bot/dnd.rs
T
Puechberty Arthur 4d92be1ad5 feat: restrict commands from being used in DMs
- Added `allow_in_dm: false` to various moderation, utility, and role management commands to prevent their usage in direct messages.
- Updated the message event handler to check for the `allow_in_dm` flag and respond appropriately when a DM command is attempted.
2026-04-10 08:53:48 +02:00

46 lines
1.3 KiB
Rust

use serenity::builder::CreateEmbed;
use serenity::model::prelude::*;
use serenity::prelude::*;
use crate::commands::common::send_embed;
use crate::db::{DbPoolKey, set_bot_status};
pub async fn handle_dnd(ctx: &Context, msg: &Message) {
ctx.dnd();
let bot_id = ctx.cache.current_user().id;
let pool = {
let data = ctx.data.read().await;
data.get::<DbPoolKey>().cloned()
};
if let Some(pool) = pool {
let _ = set_bot_status(&pool, bot_id, "dnd").await;
}
let embed = CreateEmbed::new()
.title("Statut mis à jour")
.description("Nouveau statut: dnd")
.color(0x57F287);
send_embed(ctx, msg, embed).await;
}
pub struct DndCommand;
pub static COMMAND_DESCRIPTOR: DndCommand = DndCommand;
impl crate::commands::command_contract::CommandSpec for DndCommand {
fn metadata(&self) -> crate::commands::command_contract::CommandMetadata {
crate::commands::command_contract::CommandMetadata {
name: "dnd",
category: "bot",
params: "aucun",
summary: "Passe le bot en dnd",
description: "Change le statut du bot en do not disturb et sauvegarde ce statut.",
examples: &["+dnd", "+dd", "+help dnd"],
default_aliases: &["dnm"],
allow_in_dm: false,
default_permission: 8,
}
}
}