pub struct SlashCommandAttachmentOption { /* private fields */ }Expand description
Builds an attachment option of a slash command: a file users upload.
discord.js counterpart: SlashCommandAttachmentOption.
Implementations§
Source§impl SlashCommandAttachmentOption
impl SlashCommandAttachmentOption
Sourcepub fn new(
name: impl Into<CompactString>,
description: impl Into<CompactString>,
) -> Self
pub fn new( name: impl Into<CompactString>, description: impl Into<CompactString>, ) -> Self
Creates an optional option named name (1-32 lower-case letters, numbers, -,
_ or ʼ) and described by description (1-100 characters).
discord.js counterpart: the constructor of the option builders (SlashCommandStringOption, …), with setName.
Sourcepub fn required(self, required: bool) -> Self
pub fn required(self, required: bool) -> Self
Sets whether users must fill the option in (default: no). Required options must come before optional ones.
discord.js counterpart: setRequired.
Sourcepub fn name_localization(
self,
locale: Locale,
name: impl Into<CompactString>,
) -> Self
pub fn name_localization( self, locale: Locale, name: impl Into<CompactString>, ) -> Self
Sets the name shown to users whose Discord language is locale. It follows the same
rules as the name itself.
discord.js counterpart: setNameLocalization.
Sourcepub fn name_localizations<N: Into<CompactString>>(
self,
localizations: impl IntoIterator<Item = (Locale, N)>,
) -> Self
pub fn name_localizations<N: Into<CompactString>>( self, localizations: impl IntoIterator<Item = (Locale, N)>, ) -> Self
Sets several name translations at once, keeping those set before (a locale given again gets the new name).
discord.js counterpart: setNameLocalizations (which replaces them all).
Sourcepub fn description_localization(
self,
locale: Locale,
description: impl Into<CompactString>,
) -> Self
pub fn description_localization( self, locale: Locale, description: impl Into<CompactString>, ) -> Self
Sets the description shown to users whose Discord language is locale (1-100
characters, like the description).
discord.js counterpart: setDescriptionLocalization.
Sourcepub fn description_localizations<D: Into<CompactString>>(
self,
localizations: impl IntoIterator<Item = (Locale, D)>,
) -> Self
pub fn description_localizations<D: Into<CompactString>>( self, localizations: impl IntoIterator<Item = (Locale, D)>, ) -> Self
Sets several description translations at once, keeping those set before.
discord.js counterpart: setDescriptionLocalizations (which replaces them all).
Sourcepub fn build(self) -> Result<CommandOption, ValidationError>
pub fn build(self) -> Result<CommandOption, ValidationError>
Checks the option on its own and returns it as a [CommandOption]; the paths
in a ValidationError start at its fields (name, choices[0].name).
Adding the builder to a command checks it as part of the command instead.
discord.js counterpart: toJSON of the option builders (SlashCommandStringOption, …).
§Errors
The first ValidationError found, as in
SlashCommandBuilder::build.
Sourcepub fn build_unchecked(self) -> CommandOption
pub fn build_unchecked(self) -> CommandOption
Returns the option without any check (D-180).
discord.js counterpart: toJSON of the option builders with validation off (disableValidators).
Source§impl SlashCommandAttachmentOption
impl SlashCommandAttachmentOption
Sourcepub fn file_types<T: Into<CompactString>>(
self,
file_types: impl IntoIterator<Item = T>,
) -> Self
pub fn file_types<T: Into<CompactString>>( self, file_types: impl IntoIterator<Item = T>, ) -> Self
Sets the file types
users may pick, as extensions such as png (all when not set), replacing those set
before.
discord.js counterpart: none (@discordjs/builders has no file types).