Derive Macro serenity_commands::Command

source ·
#[derive(Command)]
{
    // Attributes available to this derive:
    #[command]
}
Expand description

Derives Command.

§Examples

§Struct

Each field must implement BasicOption.

use serenity_commands::Command;

#[derive(Command)]
struct Add {
    /// First number.
    a: f64,

    /// Second number.
    b: f64,
}

§Enum

Each field of named variants must implement BasicOption.

The inner type of newtype variants must implement SubCommandGroup (or, by extension, SubCommand, as SubCommand is a sub-trait of SubCommandGroup).

use serenity_commands::{Command, SubCommandGroup};

#[derive(SubCommandGroup)]
enum ModUtilities {
    // ...
}

#[derive(Command)]
enum Utilities {
    /// Ping the bot.
    Ping,

    /// Add two numbers.
    Add {
        /// First number.
        a: f64,

        /// Second number.
        b: f64,
    },

    /// Moderation utilities.
    Mod(ModUtilities),
}