Struct CreateCommandOption

Source
pub struct CreateCommandOption(/* private fields */);
Expand description

A builder for creating a new CommandOption.

Self::kind, Self::name, and Self::description are required fields.

Discord docs.

Implementations§

Source§

impl CreateCommandOption

Source

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.

Source

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

Sets the CommandOptionType, replacing the current value as set in Self::new.

Source

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

Source

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

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.

Source

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

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

Sets if this option is required or optional.

Note: This defaults to false.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_autocomplete(self, value: bool) -> 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 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.

Source

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.

Source

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.

Source

pub fn min_int_value(self, value: u64) -> Self

Sets the minimum permitted value for this integer option

Source

pub fn max_int_value(self, value: u64) -> Self

Sets the maximum permitted value for this integer option

Source

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

Sets the minimum permitted value for this number option

Source

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

Sets the maximum permitted value for this number option

Source

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.

Source

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

Source§

fn clone(&self) -> CreateCommandOption

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 CreateCommandOption

Source§

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

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

impl Serialize for CreateCommandOption

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneDebuggableStorage for T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> CloneableStorage for T
where T: Any + Send + Sync + Clone,

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 T
where 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

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

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
Source§

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T