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 u8)

🔬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>,