From 87e8467dafec58d943d60de4ac1a8711c08528f4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Feb 2026 15:27:07 +0100 Subject: [PATCH] feat(commands/moderation): updating the clear to be on help menu --- src/commands/moderation/clear.rs | 44 ++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/commands/moderation/clear.rs b/src/commands/moderation/clear.rs index 1bdd982..1ac4f3e 100644 --- a/src/commands/moderation/clear.rs +++ b/src/commands/moderation/clear.rs @@ -1,25 +1,24 @@ -use crate::commands::{CommandEntry, SlashCommand}; +use std::sync::atomic::AtomicU64; + +use crate::commands::{CommandCategory, CommandEntry, SlashCommand}; use crate::config::EmojiConfig; use serenity::all::{ - ChannelType, - CommandInteraction, - CommandOption, - CommandOptionType, - Context, - CreateCommand, - CreateCommandOption, - CreateInteractionResponse, - CreateInteractionResponseMessage, - EditInteractionResponse, - GetMessages, - Message, - MessageId, - Permissions + CommandInteraction, CommandOption, CommandOptionType, Context, CreateCommand, CreateCommandOption, CreateInteractionResponse, CreateInteractionResponseMessage, EditInteractionResponse, GetMessages, InteractionContext, Message, MessageId, Permissions }; use sqlx::PgPool; -pub struct Clear; +pub struct Clear { + pub command_id: AtomicU64, +} + +impl Clear { + pub fn new() -> Self { + Self { + command_id: AtomicU64::new(0), + } + } +} #[serenity::async_trait] impl SlashCommand for Clear { @@ -31,6 +30,14 @@ impl SlashCommand for Clear { "Clear X message (X given in the parameters)" } + fn category(&self) -> &'static CommandCategory { + &CommandCategory::Moderation + } + + fn command_id_ref(&self) -> &AtomicU64 { + &self.command_id + } + fn register(&self) -> CreateCommand { println!("\t✅ | {}", self.name()); let mut options: Vec = Vec::new(); @@ -45,6 +52,9 @@ impl SlashCommand for Clear { .description(self.description()) .default_member_permissions(Permissions::MANAGE_MESSAGES) .set_options(options) + .contexts(vec![ + InteractionContext::Guild, + ]) } async fn run( @@ -91,5 +101,5 @@ impl SlashCommand for Clear { } inventory::submit! { - CommandEntry { create: || Box::new(Clear) } + CommandEntry { create: || Box::new(Clear::new()) } }