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() +}