twilight_model::application::command

Struct CommandOption

source
pub struct CommandOption {
Show 14 fields pub autocomplete: Option<bool>, pub channel_types: Option<Vec<ChannelType>>, pub choices: Option<Vec<CommandOptionChoice>>, pub description: String, pub description_localizations: Option<HashMap<String, String>>, pub kind: CommandOptionType, pub max_length: Option<u16>, pub max_value: Option<CommandOptionValue>, pub min_length: Option<u16>, pub min_value: Option<CommandOptionValue>, pub name: String, pub name_localizations: Option<HashMap<String, String>>, pub options: Option<Vec<CommandOption>>, pub required: Option<bool>,
}
Expand description

Option for a Command.

Fields not applicable to the command option’s CommandOptionType should be set to None.

Fields’ default values may be used by setting them to None.

Choices, descriptions and names may be localized in any available locale, see Discord Docs/Localization.

Fields§

§autocomplete: Option<bool>

Whether the command supports autocomplete.

Applicable for options of type Integer, Number, and String.

Defaults to false.

Note: may not be set to true if choices are set.

§channel_types: Option<Vec<ChannelType>>

List of possible channel types users can select from.

Applicable for options of type Channel.

Defaults to any channel type.

§choices: Option<Vec<CommandOptionChoice>>

List of predetermined choices users can select from.

Applicable for options of type Integer, Number, and String.

Defaults to no choices; users may input a value of their choice.

Must be at most 25 options.

Note: all choices must be of the same type.

§description: String

Description of the option. Must be 100 characters or less.

§description_localizations: Option<HashMap<String, String>>

Localization dictionary for the description field.

Defaults to no localizations.

Keys must be valid locales and values must be 100 characters or less.

§kind: CommandOptionType

Type of option.

§max_length: Option<u16>

Maximum allowed value length.

Applicable for options of type String.

Defaults to 6000.

Must be at least 1 and at most 6000.

§max_value: Option<CommandOptionValue>

Maximum allowed value.

Applicable for options of type Integer and Number.

Defaults to no maximum.

§min_length: Option<u16>

Minimum allowed value length.

Applicable for options of type String.

Defaults to 0.

Must be at most 6000.

§min_value: Option<CommandOptionValue>

Minimum allowed value.

Applicable for options of type Integer and Number.

Defaults to no minimum.

§name: String

Name of the option. Must be 32 characters or less.

§name_localizations: Option<HashMap<String, String>>

Localization dictionary for the name field.

Defaults to no localizations.

Keys must be valid locales and values must be 32 characters or less.

§options: Option<Vec<CommandOption>>

Nested options.

Applicable for options of type SubCommand and SubCommandGroup.

Defaults to no options.

Note: at least one option is required and SubCommandGroup may only contain SubCommands.

See Discord Docs/Subcommands and Subcommand Groups.

§required: Option<bool>

Whether the option is required.

Applicable for all options except those of type SubCommand and SubCommandGroup.

Defaults to false.

Trait Implementations§

source§

impl Clone for CommandOption

source§

fn clone(&self) -> CommandOption

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 CommandOption

source§

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

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

impl<'de> Deserialize<'de> for CommandOption

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for CommandOption

source§

fn eq(&self, other: &CommandOption) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for CommandOption

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

impl StructuralPartialEq for CommandOption

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> CloneToUninit for T
where T: Clone,

source§

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

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,