pub struct CommandParameter<U, E> {
pub name: String,
pub name_localizations: HashMap<String, String>,
pub description: Option<String>,
pub description_localizations: HashMap<String, String>,
pub required: bool,
pub channel_types: Option<Vec<ChannelType>>,
pub choices: Vec<CommandParameterChoice>,
pub type_setter: Option<fn(CreateCommandOption) -> CreateCommandOption>,
pub autocomplete_callback: Option<for<'a> fn(ApplicationContext<'a, U, E>, &'a str) -> BoxFuture<'a, Result<CreateAutocompleteResponse, SlashArgError>>>,
/* private fields */
}Expand description
A single parameter of a crate::Command
Fields§
§name: StringName of this command parameter
name_localizations: HashMap<String, String>Localized names with locale string as the key (slash-only)
description: Option<String>Description of the command. Required for slash commands
description_localizations: HashMap<String, String>Localized descriptions with locale string as the key (slash-only)
required: booltrue is this parameter is required, false if it’s optional or variadic
channel_types: Option<Vec<ChannelType>>If this parameter is a channel, users can only enter these channel types in a slash command
Prefix commands are currently unaffected by this
choices: Vec<CommandParameterChoice>If this parameter is a choice parameter, this is the fixed list of options
type_setter: Option<fn(CreateCommandOption) -> CreateCommandOption>Closure that sets this parameter’s type and min/max value in the given builder
For example a u32 CommandParameter would store this as the Self::type_setter:
|b| b.kind(serenity::CommandOptionType::Integer).min_int_value(0).max_int_value(u64::MAX)autocomplete_callback: Option<for<'a> fn(ApplicationContext<'a, U, E>, &'a str) -> BoxFuture<'a, Result<CreateAutocompleteResponse, SlashArgError>>>Optionally, a callback that is invoked on autocomplete interactions. This closure should extract the partial argument from the given JSON value and generate the autocomplete response which contains the list of autocomplete suggestions.
Implementations§
Source§impl<U, E> CommandParameter<U, E>
impl<U, E> CommandParameter<U, E>
Sourcepub fn create_as_slash_command_option(&self) -> Option<CreateCommandOption>
pub fn create_as_slash_command_option(&self) -> Option<CreateCommandOption>
Generates a slash command parameter builder from this CommandParameter instance. This
can be used to register the command on Discord’s servers
Trait Implementations§
Source§impl<U: Clone, E: Clone> Clone for CommandParameter<U, E>
impl<U: Clone, E: Clone> Clone for CommandParameter<U, E>
Source§fn clone(&self) -> CommandParameter<U, E>
fn clone(&self) -> CommandParameter<U, E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more