mirror of
https://github.com/arthur-pbty/shadowbot.git
synced 2026-06-03 23:36:25 +02:00
modify commands categories
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
use serenity::model::prelude::*;
|
||||
use serenity::prelude::*;
|
||||
|
||||
use crate::commands::admin_common::ensure_owner;
|
||||
use crate::commands::common::send_embed;
|
||||
use crate::db::{DbPoolKey, clear_blacklist};
|
||||
|
||||
pub async fn handle_clear_bl(ctx: &Context, msg: &Message) {
|
||||
if ensure_owner(ctx, msg).await.is_err() {
|
||||
return;
|
||||
}
|
||||
|
||||
let bot_id = ctx.cache.current_user().id;
|
||||
let pool = {
|
||||
let data = ctx.data.read().await;
|
||||
data.get::<DbPoolKey>().cloned()
|
||||
};
|
||||
|
||||
let Some(pool) = pool else {
|
||||
let embed = serenity::builder::CreateEmbed::new()
|
||||
.title("Erreur")
|
||||
.description("DB indisponible.")
|
||||
.color(0xED4245);
|
||||
send_embed(ctx, msg, embed).await;
|
||||
return;
|
||||
};
|
||||
|
||||
let count = clear_blacklist(&pool, bot_id).await.unwrap_or(0);
|
||||
let embed = serenity::builder::CreateEmbed::new()
|
||||
.title("Blacklist réinitialisée")
|
||||
.description(format!("{} membre(s) retiré(s) de la blacklist.", count))
|
||||
.color(0x57F287);
|
||||
send_embed(ctx, msg, embed).await;
|
||||
}
|
||||
|
||||
pub struct ClearBlCommand;
|
||||
pub static COMMAND_DESCRIPTOR: ClearBlCommand = ClearBlCommand;
|
||||
|
||||
impl crate::commands::command_contract::CommandSpec for ClearBlCommand {
|
||||
fn metadata(&self) -> crate::commands::command_contract::CommandMetadata {
|
||||
crate::commands::command_contract::CommandMetadata {
|
||||
name: "clear_bl",
|
||||
category: "administration",
|
||||
params: "aucun",
|
||||
summary: "Vide la blacklist globale",
|
||||
description: "Supprime toutes les entrees de la blacklist globale.",
|
||||
examples: &["+clear bl", "+cl", "+help clear bl"],
|
||||
default_aliases: &["cbl"],
|
||||
default_permission: 9,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user