mirror of
https://github.com/arthur-pbty/shadowbot.git
synced 2026-06-03 15:07:37 +02:00
e1016e0af1
- Updated `handle_idle`, `handle_invisible`, `handle_online`, `handle_listen`, `handle_playto`, `handle_stream`, `handle_watch`, and `handle_remove_activity` functions to use a unified approach for setting bot status and sending embed messages. - Removed dependency on `botconfig_common` and replaced it with direct database interactions for status management. - Added new helper functions for logging and moderation channel management. - Introduced permission handling improvements in `set` command with better error messages and user feedback. - Created new utility functions for parsing user and role IDs, ensuring better command access control.
71 lines
1.9 KiB
Rust
71 lines
1.9 KiB
Rust
use chrono::Utc;
|
|
use serenity::builder::CreateEmbed;
|
|
use serenity::model::prelude::*;
|
|
use serenity::prelude::*;
|
|
|
|
use crate::commands::common::{send_embed, theme_color};
|
|
use crate::commands::moderation_sanction_helpers::{add_sanction, handle_timeout, parse_targets};
|
|
|
|
pub async fn handle_mute(ctx: &Context, msg: &Message, args: &[&str]) {
|
|
let Some(guild_id) = msg.guild_id else {
|
|
return;
|
|
};
|
|
if args.is_empty() {
|
|
return;
|
|
}
|
|
|
|
let targets = parse_targets(args[0]).await;
|
|
if targets.is_empty() {
|
|
return;
|
|
}
|
|
|
|
let expires_at = Some(Utc::now() + chrono::Duration::seconds(28 * 24 * 3600));
|
|
let reason = if args.len() > 1 {
|
|
args[1..].join(" ")
|
|
} else {
|
|
"Aucune raison".to_string()
|
|
};
|
|
|
|
let affected = handle_timeout(ctx, guild_id, &targets, expires_at).await;
|
|
|
|
for uid in &targets {
|
|
add_sanction(
|
|
ctx,
|
|
guild_id,
|
|
*uid,
|
|
msg.author.id,
|
|
"mute",
|
|
&reason,
|
|
None,
|
|
expires_at,
|
|
)
|
|
.await;
|
|
}
|
|
|
|
send_embed(
|
|
ctx,
|
|
msg,
|
|
CreateEmbed::new()
|
|
.title("Mute")
|
|
.description(format!("{} membre(s) mute.", affected))
|
|
.color(theme_color(ctx).await),
|
|
)
|
|
.await;
|
|
}
|
|
pub struct MuteCommand;
|
|
pub static COMMAND_DESCRIPTOR: MuteCommand = MuteCommand;
|
|
impl crate::commands::command_contract::CommandSpec for MuteCommand {
|
|
fn metadata(&self) -> crate::commands::command_contract::CommandMetadata {
|
|
crate::commands::command_contract::CommandMetadata {
|
|
name: "mute",
|
|
category: "admin",
|
|
params: "<@membre/ID[,..]> [raison]",
|
|
summary: "Mute un membre",
|
|
description: "Applique un mute a un ou plusieurs membres.",
|
|
examples: &["+mute @User abus"],
|
|
default_aliases: &["tmute"],
|
|
default_permission: 8,
|
|
}
|
|
}
|
|
}
|