pub struct CreateCommandOption(/* private fields */);
Expand description
A builder for creating a new CommandOption
.
Self::kind
, Self::name
, and Self::description
are required fields.
Implementations§
Source§impl CreateCommandOption
impl CreateCommandOption
Sourcepub fn new(
kind: CommandOptionType,
name: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn new( kind: CommandOptionType, name: impl Into<String>, description: impl Into<String>, ) -> Self
Creates a new builder with the given option type, name, and description, leaving all other fields empty.
Sourcepub fn kind(self, kind: CommandOptionType) -> Self
pub fn kind(self, kind: CommandOptionType) -> Self
Sets the CommandOptionType
, replacing the current value as set in Self::new
.
Sourcepub fn name(self, name: impl Into<String>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Sets the name of the option, replacing the current value as set in Self::new
.
Note: Must be between 1 and 32 lowercase characters, matching r"^[\w-]{1,32}$"
.
Sourcepub fn name_localized(
self,
locale: impl Into<String>,
name: impl Into<String>,
) -> Self
pub fn name_localized( self, locale: impl Into<String>, name: impl Into<String>, ) -> Self
Specifies a localized name of the option.
.name("age")
.name_localized("zh-CN", "岁数")
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Sets the description for the option, replacing the current value as set in Self::new
.
Note: Must be between 1 and 100 characters.
Sourcepub fn description_localized(
self,
locale: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn description_localized( self, locale: impl Into<String>, description: impl Into<String>, ) -> Self
Specifies a localized description of the option.
.description("Wish a friend a happy birthday")
.description_localized("zh-CN", "祝你朋友生日快乐")
Sourcepub fn required(self, required: bool) -> Self
pub fn required(self, required: bool) -> Self
Sets if this option is required or optional.
Note: This defaults to false
.
Sourcepub fn add_int_choice(self, name: impl Into<String>, value: i32) -> Self
pub fn add_int_choice(self, name: impl Into<String>, value: i32) -> 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(
self,
name: impl Into<String>,
value: i32,
locales: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
) -> Self
pub fn add_int_choice_localized( self, name: impl Into<String>, value: i32, locales: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>, ) -> Self
Adds a localized optional int-choice. See Self::add_int_choice
for more info.
Sourcepub fn add_string_choice(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn add_string_choice( self, name: impl Into<String>, value: impl Into<String>, ) -> 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(
self,
name: impl Into<String>,
value: impl Into<String>,
locales: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
) -> Self
pub fn add_string_choice_localized( self, name: impl Into<String>, value: impl Into<String>, locales: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>, ) -> Self
Adds a localized optional string-choice. See Self::add_string_choice
for more info.
Sourcepub fn add_number_choice(self, name: impl Into<String>, value: f64) -> Self
pub fn add_number_choice(self, name: impl Into<String>, value: f64) -> 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(
self,
name: impl Into<String>,
value: f64,
locales: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
) -> Self
pub fn add_number_choice_localized( self, name: impl Into<String>, value: f64, locales: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>, ) -> Self
Adds a localized optional number-choice. See Self::add_number_choice
for more info.
Sourcepub fn set_autocomplete(self, value: bool) -> Self
pub fn set_autocomplete(self, value: bool) -> Self
Optionally enable/disable autocomplete interactions for this option.
Notes:
- May not be set to
true
ifchoices
are set - Options using
autocomplete
are not confined to only use given choices
Sourcepub fn set_sub_options(
self,
sub_options: impl IntoIterator<Item = CreateCommandOption>,
) -> Self
pub fn set_sub_options( self, sub_options: impl IntoIterator<Item = CreateCommandOption>, ) -> Self
If the option is a SubCommandGroup
or SubCommand
, nested options are its parameters.
This will overwrite any existing sub-options. To add a sub-option to the existing list, use
Self::add_sub_option
.
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(self, sub_option: CreateCommandOption) -> Self
pub fn add_sub_option(self, sub_option: CreateCommandOption) -> 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(self, channel_types: Vec<ChannelType>) -> Self
pub fn channel_types(self, channel_types: Vec<ChannelType>) -> Self
If the option is a Channel
, it will only be able to show these types.
Sourcepub fn min_int_value(self, value: u64) -> Self
pub fn min_int_value(self, value: u64) -> Self
Sets the minimum permitted value for this integer option
Sourcepub fn max_int_value(self, value: u64) -> Self
pub fn max_int_value(self, value: u64) -> Self
Sets the maximum permitted value for this integer option
Sourcepub fn min_number_value(self, value: f64) -> Self
pub fn min_number_value(self, value: f64) -> Self
Sets the minimum permitted value for this number option
Sourcepub fn max_number_value(self, value: f64) -> Self
pub fn max_number_value(self, value: f64) -> Self
Sets the maximum permitted value for this number option
Sourcepub fn min_length(self, value: u16) -> Self
pub fn min_length(self, value: u16) -> 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(self, value: u16) -> Self
pub fn max_length(self, value: u16) -> 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 CreateCommandOption
impl Clone for CreateCommandOption
Source§fn clone(&self) -> CreateCommandOption
fn clone(&self) -> CreateCommandOption
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more