pub struct SlashCommandChannelOption { /* private fields */ }Expand description
Builds a channel option of a slash command: a channel or category, optionally only of some types.
discord.js counterpart: SlashCommandChannelOption.
§Examples
use djs_builders::SlashCommandChannelOption;
use djs_model::channel::ChannelType;
let option = SlashCommandChannelOption::new("channel", "Where to post")
.channel_types([ChannelType::GuildText, ChannelType::GuildAnnouncement])
.build()
.unwrap();
assert_eq!(option.name(), "channel");Implementations§
Source§impl SlashCommandChannelOption
impl SlashCommandChannelOption
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 SlashCommandChannelOption
impl SlashCommandChannelOption
Sourcepub fn channel_types(
self,
channel_types: impl IntoIterator<Item = ChannelType>,
) -> Self
pub fn channel_types( self, channel_types: impl IntoIterator<Item = ChannelType>, ) -> Self
Sets the channel types offered (all when not set), replacing those set before.
discord.js counterpart: addChannelTypes.