Derive Macro serenity_commands::CommandData
source · #[derive(CommandData)]
{
// Attributes available to this derive:
#[command]
}
Expand description
Derive the CommandData
trait.
This creates a top-level utility structure which can list all of its
commands (for use with GuildId::set_commands
, etc.) and extract data
from CommandInteraction
s.
This macro only supports enum
s, as it is intended to select from one of
many commands.
Documentation comments (///
) will be used as the commands’/options’
descriptions, and are required whenever they are expected.
Examples
- A variant with named fields is a command with the specified options.
- A newtype variant is a command which delegates the implementation to the
inner type, which must implement
Command
. - A unit variant is a command with no options.
use serenity_commands::CommandData;
#[derive(CommandData)]
enum Commands {
/// Ping the bot.
Ping,
/// Echo a message.
Echo {
/// The message to echo.
message: String,
},
/// Perform math operations.
Math(MathCommand),
}