#[command]Expand description
Converts an async-compatible function into a builder and modifies function’s body
to parse all required arguments, for further information about the behaviour of this macro, see
the implementation.
By an async-compatible function it’s meant a function with a minimum of one argument,
which must be an &SlashContext<T>, which is always given and also used to parse all arguments.
§Usage:
This macro can be used two ways:
- Without arguments, as #[command], which takes the caller function name as the name of the command.
- Providing the name, as #[command("command name")] which takes the provided name as the command name.When marking a function with this attribute macro, you must provide a description of the
command that will be seen on discord when using the command, this is made by adding a
description attribute, which can be added two ways:
- List way: #[description("Some description")]
- Named value way: #[description = "Some description"]§Arguments:
You must provide another description attribute for every argument describing what they
are, this description will be seen on discord when filling up the argument. This needs to be
done with all the arguments except the context, which must be the first one, the accepted
syntax is the same as the previous description one.
§Renaming:
Adding a rename attribute is optional, but can be used to modify the name of the argument seen
in discord, it is allowed to have only one rename attribute per argument and the attribute can
be used the same ways a the description one.
§Autocompletion:
Adding an autocomplete attribute is also optional, but it allows the developer to complete
the user’s input for an argument. This attribute is used the same way as the description one,
but it must point to a function marked with the #[autocomplete] attribute macro.
§Specifying required permissions
It is possible to specify the permissions needed to execute the command by using the
#[required_permissions] attribute. It accepts as input a list of comma separated
twilight permissions.
For example, to specify that a user needs to have administrator permissions to execute a command,
the attribute would be used like this #[required_permissions(ADMINISTRATOR)].