From cc7369bcffe82877acdf6af2563f3612cd8f590a Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 12 Feb 2026 16:18:29 +0100 Subject: [PATCH] feat(commands): adding mod.rs --- src/commands/mod.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/commands/mod.rs diff --git a/src/commands/mod.rs b/src/commands/mod.rs new file mode 100644 index 0000000..ed91f72 --- /dev/null +++ b/src/commands/mod.rs @@ -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, +} + +inventory::collect!(CommandEntry); + +pub fn all_commands() -> Vec> { + inventory::iter:: + .into_iter() + .map(|entry| (entry.create)()) + .collect() +}