feat(commands/mod): adding the category for help command
- adding stuff to take command variable
This commit is contained in:
parent
d0afd2986c
commit
51e95d3f93
1 changed files with 34 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
use serenity::all::{CommandInteraction, Context, CreateCommand};
|
||||
use sqlx::PgPool;
|
||||
|
||||
|
|
@ -5,10 +7,42 @@ use crate::config::EmojiConfig;
|
|||
|
||||
include!("./mod_gen.rs");
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum CommandCategory {
|
||||
Moderation,
|
||||
Utils,
|
||||
}
|
||||
|
||||
impl CommandCategory {
|
||||
pub fn emoji(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Utils => "🌐",
|
||||
Self::Moderation => "🛡️",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Utils => "Utils",
|
||||
Self::Moderation => "Moderation",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[serenity::async_trait]
|
||||
pub trait SlashCommand: Send + Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
fn description(&self) -> &'static str;
|
||||
fn category(&self) -> &'static CommandCategory;
|
||||
fn command_id_ref(&self) -> &AtomicU64;
|
||||
|
||||
fn get_id(&self) -> u64 {
|
||||
self.command_id_ref().load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
fn set_id(&self, id: u64) {
|
||||
self.command_id_ref().store(id, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
fn register(&self) -> CreateCommand;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue