26 lines
754 B
Rust

use serenity::builder::CreateCommand;
use serenity::prelude::Context;
use serenity::model::interactions::Interaction;
use anyhow::Result;
/// Defines a slash command with its registration and handler.
pub struct SlashCommand {
pub name: &'static str,
pub register: fn(&mut CreateCommand) -> &mut CreateCommand,
pub handler: fn(Context, Interaction) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<()>> + Send>>,
}
inventory::collect!(SlashCommand);
/// Returns all registered slash commands.
pub fn get_slash_commands() -> Vec<&'static SlashCommand> {
inventory::iter::<SlashCommand>
.into_iter()
.collect()
}
// Register individual command modules
pub mod ping;
pub mod join;
pub mod play;
pub mod leave;