Skip to main content

streamocracy/commands/
mod.rs

1use crate::config::Config;
2use serenity::all::{CommandInteraction, Context, CreateCommand};
3
4pub mod ping;
5pub mod votekick;
6
7/// Trait for slash commands.
8#[serenity::async_trait]
9pub trait SlashCommand: Send + Sync {
10    /// The command name (must match Discord command name).
11    fn name(&self) -> &'static str;
12
13    /// Register the command with Discord.
14    fn register(&self) -> CreateCommand;
15
16    /// Execute the command.
17    async fn run(&self, ctx: Context, command: CommandInteraction, config: Config);
18}
19
20/// Get all available commands.
21pub fn get_commands() -> Vec<Box<dyn SlashCommand>> {
22    vec![
23        Box::new(ping::PingCommand),
24        Box::new(votekick::VotekickCommand),
25    ]
26}