Struct serenity::builder::CreateApplicationCommandOption
source · pub struct CreateApplicationCommandOption(pub HashMap<&'static str, Value>);builder only.Expand description
A builder for creating a new CommandOption.
Self::kind, Self::name, and Self::description are required fields.
Tuple Fields§
§0: HashMap<&'static str, Value>Implementations§
source§impl CreateApplicationCommandOption
impl CreateApplicationCommandOption
sourcepub fn kind(&mut self, kind: CommandOptionType) -> &mut Self
pub fn kind(&mut self, kind: CommandOptionType) -> &mut Self
Sets the CommandOptionType.
sourcepub fn name<D: ToString>(&mut self, name: D) -> &mut Self
pub fn name<D: ToString>(&mut self, name: D) -> &mut Self
Sets the name of the option.
Note: Must be between 1 and 32 lowercase characters, matching r"^[\w-]{1,32}$".
sourcepub fn name_localized<D: ToString, E: ToString>(
&mut self,
locale: E,
name: D
) -> &mut Self
pub fn name_localized<D: ToString, E: ToString>( &mut self, locale: E, name: D ) -> &mut Self
Specifies a localized name of the option.
.name("age")
.name_localized("zh-CN", "岁数")sourcepub fn description<D: ToString>(&mut self, description: D) -> &mut Self
pub fn description<D: ToString>(&mut self, description: D) -> &mut Self
Sets the description for the option.
Note: Must be between 1 and 100 characters.
sourcepub fn description_localized<D: ToString, E: ToString>(
&mut self,
locale: E,
description: D
) -> &mut Self
pub fn description_localized<D: ToString, E: ToString>( &mut self, locale: E, description: D ) -> &mut Self
Specifies a localized description of the option.
.description("Wish a friend a happy birthday")
.description_localized("zh-CN", "祝你朋友生日快乐")sourcepub fn default_option(&mut self, default: bool) -> &mut Self
pub fn default_option(&mut self, default: bool) -> &mut Self
The first required option for the user to complete.
Note: Only one option can be default.
sourcepub fn required(&mut self, required: bool) -> &mut Self
pub fn required(&mut self, required: bool) -> &mut Self
Sets if this option is required or optional.
Note: This defaults to false.
sourcepub fn add_int_choice<D: ToString>(&mut self, name: D, value: i32) -> &mut Self
pub fn add_int_choice<D: ToString>(&mut self, name: D, value: i32) -> &mut Self
Adds an optional int-choice.
Note: There can be no more than 25 choices set. Name must be between 1 and 100 characters. Value must be between -2^53 and 2^53.
sourcepub fn add_int_choice_localized<L: ToString, D: ToString>(
&mut self,
name: D,
value: i32,
locales: impl IntoIterator<Item = (L, D)>
) -> &mut Self
pub fn add_int_choice_localized<L: ToString, D: ToString>( &mut self, name: D, value: i32, locales: impl IntoIterator<Item = (L, D)> ) -> &mut Self
Adds a localized optional int-choice. See Self::add_int_choice for more info.
sourcepub fn add_string_choice<D: ToString, E: ToString>(
&mut self,
name: D,
value: E
) -> &mut Self
pub fn add_string_choice<D: ToString, E: ToString>( &mut self, name: D, value: E ) -> &mut Self
Adds an optional string-choice.
Note: There can be no more than 25 choices set. Name must be between 1 and 100 characters. Value must be up to 100 characters.
sourcepub fn add_string_choice_localized<L: ToString, D: ToString, E: ToString>(
&mut self,
name: D,
value: E,
locales: impl IntoIterator<Item = (L, D)>
) -> &mut Self
pub fn add_string_choice_localized<L: ToString, D: ToString, E: ToString>( &mut self, name: D, value: E, locales: impl IntoIterator<Item = (L, D)> ) -> &mut Self
Adds a localized optional string-choice. See Self::add_string_choice for more info.
sourcepub fn add_number_choice<D: ToString>(
&mut self,
name: D,
value: f64
) -> &mut Self
pub fn add_number_choice<D: ToString>( &mut self, name: D, value: f64 ) -> &mut Self
Adds an optional number-choice.
Note: There can be no more than 25 choices set. Name must be between 1 and 100 characters. Value must be between -2^53 and 2^53.
sourcepub fn add_number_choice_localized<L: ToString, D: ToString>(
&mut self,
name: D,
value: f64,
locales: impl IntoIterator<Item = (L, D)>
) -> &mut Self
pub fn add_number_choice_localized<L: ToString, D: ToString>( &mut self, name: D, value: f64, locales: impl IntoIterator<Item = (L, D)> ) -> &mut Self
Adds a localized optional number-choice. See Self::add_number_choice for more info.
sourcepub fn set_autocomplete(&mut self, value: bool) -> &mut Self
pub fn set_autocomplete(&mut self, value: bool) -> &mut Self
Optionally enable/disable autocomplete interactions for this option.
Notes:
- May not be set to
trueifchoicesare set - Options using
autocompleteare not confined to only use given choices
sourcepub fn create_sub_option<F>(&mut self, f: F) -> &mut Selfwhere
F: FnOnce(&mut CreateApplicationCommandOption) -> &mut CreateApplicationCommandOption,
pub fn create_sub_option<F>(&mut self, f: F) -> &mut Selfwhere F: FnOnce(&mut CreateApplicationCommandOption) -> &mut CreateApplicationCommandOption,
If the option is a SubCommandGroup or SubCommand, nested options are its parameters.
Note: A command can have up to 25 subcommand groups, or subcommands. A subcommand group can have up to 25 subcommands. A subcommand can have up to 25 options.
sourcepub fn add_sub_option(
&mut self,
sub_option: CreateApplicationCommandOption
) -> &mut Self
pub fn add_sub_option( &mut self, sub_option: CreateApplicationCommandOption ) -> &mut Self
If the option is a SubCommandGroup or SubCommand, nested options are its parameters.
Note: A command can have up to 25 subcommand groups, or subcommands. A subcommand group can have up to 25 subcommands. A subcommand can have up to 25 options.
sourcepub fn channel_types(&mut self, channel_types: &[ChannelType]) -> &mut Self
pub fn channel_types(&mut self, channel_types: &[ChannelType]) -> &mut Self
If the option is a Channel, it will only be able to show these types.
sourcepub fn min_int_value(&mut self, value: impl ToNumber) -> &mut Self
pub fn min_int_value(&mut self, value: impl ToNumber) -> &mut Self
Sets the minimum permitted value for this integer option
sourcepub fn max_int_value(&mut self, value: impl ToNumber) -> &mut Self
pub fn max_int_value(&mut self, value: impl ToNumber) -> &mut Self
Sets the maximum permitted value for this integer option
sourcepub fn min_number_value(&mut self, value: f64) -> &mut Self
pub fn min_number_value(&mut self, value: f64) -> &mut Self
Sets the minimum permitted value for this number option
sourcepub fn max_number_value(&mut self, value: f64) -> &mut Self
pub fn max_number_value(&mut self, value: f64) -> &mut Self
Sets the maximum permitted value for this number option
sourcepub fn min_length(&mut self, value: u16) -> &mut Self
pub fn min_length(&mut self, value: u16) -> &mut Self
Sets the minimum permitted length for this string option.
The value of min_length must be greater or equal to 0.
sourcepub fn max_length(&mut self, value: u16) -> &mut Self
pub fn max_length(&mut self, value: u16) -> &mut Self
Sets the maximum permitted length for this string option.
The value of max_length must be greater or equal to 1.
Trait Implementations§
source§impl Clone for CreateApplicationCommandOption
impl Clone for CreateApplicationCommandOption
source§fn clone(&self) -> CreateApplicationCommandOption
fn clone(&self) -> CreateApplicationCommandOption
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more