pub struct CreateApplicationCommandOption(pub HashMap<&'static str, Value>);
Available on crate feature 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

source

pub fn kind(&mut self, kind: CommandOptionType) -> &mut Self

Sets the CommandOptionType.

source

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}$".

source

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", "岁数")
source

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.

source

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", "祝你朋友生日快乐")
source

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.

source

pub fn required(&mut self, required: bool) -> &mut Self

Sets if this option is required or optional.

Note: This defaults to false.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn set_autocomplete(&mut self, value: bool) -> &mut Self

Optionally enable/disable autocomplete interactions for this option.

Notes:

  • May not be set to true if choices are set
  • Options using autocomplete are not confined to only use given choices
source

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.

source

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.

source

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.

source

pub fn min_int_value(&mut self, value: impl ToNumber) -> &mut Self

Sets the minimum permitted value for this integer option

source

pub fn max_int_value(&mut self, value: impl ToNumber) -> &mut Self

Sets the maximum permitted value for this integer option

source

pub fn min_number_value(&mut self, value: f64) -> &mut Self

Sets the minimum permitted value for this number option

source

pub fn max_number_value(&mut self, value: f64) -> &mut Self

Sets the maximum permitted value for this number option

source

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.

source

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

source§

fn clone(&self) -> CreateApplicationCommandOption

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CreateApplicationCommandOption

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CreateApplicationCommandOption

source§

fn default() -> CreateApplicationCommandOption

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more