feat(commands): adding mod.rs

This commit is contained in:
Raphael 2026-02-12 16:18:29 +01:00
parent 3f5c8efd7a
commit cc7369bcff
No known key found for this signature in database

28
src/commands/mod.rs Normal file
View file

@ -0,0 +1,28 @@
use serenity::all::{
CommandInteraction, Context, CreateCommand
};
include!("./mod_gen.rs");
#[serenity::async_trait]
pub trait SlashCommand: Send + Sync {
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn register(&self) -> CreateCommand;
async fn run(&self, ctx: &Context, command: &CommandInteraction) -> Result<(), serenity::Error>;
}
pub struct CommandEntry {
pub create: fn() -> Box<dyn SlashCommand>,
}
inventory::collect!(CommandEntry);
pub fn all_commands() -> Vec<Box<dyn SlashCommand>> {
inventory::iter::<CommandEntry>
.into_iter()
.map(|entry| (entry.create)())
.collect()
}