pub struct SlashCommandSubcommandGroupBuilder { /* private fields */ }Expand description
Builds a group of subcommands
of a slash command (/command group subcommand).
Add it with SlashCommandBuilder::subcommand_group. A group contains only subcommands.
discord.js counterpart: SlashCommandSubcommandGroupBuilder.
§Examples
use djs_builders::{
SlashCommandBuilder, SlashCommandStringOption, SlashCommandSubcommandBuilder,
SlashCommandSubcommandGroupBuilder,
};
let config = SlashCommandBuilder::new("config", "Bot settings")
.subcommand_group(
SlashCommandSubcommandGroupBuilder::new("set", "Changes a setting").subcommand(
SlashCommandSubcommandBuilder::new("prefix", "Sets the prefix")
.option(SlashCommandStringOption::new("value", "The new prefix").required(true)),
),
)
.build()
.unwrap();
assert_eq!(config.options[0].options()[0].name(), "prefix");Implementations§
Source§impl SlashCommandSubcommandGroupBuilder
impl SlashCommandSubcommandGroupBuilder
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 a group named name (1-32 lower-case letters, numbers, -, _ or ʼ) and
described by description (1-100 characters).
discord.js counterpart: new SlashCommandSubcommandGroupBuilder().setName(name).
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 subcommand(self, subcommand: SlashCommandSubcommandBuilder) -> Self
pub fn subcommand(self, subcommand: SlashCommandSubcommandBuilder) -> Self
Adds a subcommand to the group (at most 25).
discord.js counterpart: addSubcommand.
Sourcepub fn build(self) -> Result<CommandOption, ValidationError>
pub fn build(self) -> Result<CommandOption, ValidationError>
Checks the group on its own and returns it as a [CommandOption].
discord.js counterpart: SlashCommandSubcommandGroupBuilder#toJSON.
§Errors
The first ValidationError found, as in SlashCommandBuilder::build (without the
8000-character total).
Sourcepub fn build_unchecked(self) -> CommandOption
pub fn build_unchecked(self) -> CommandOption
Returns the group without any check (D-180).
discord.js counterpart: SlashCommandSubcommandGroupBuilder#toJSON with validation off (disableValidators).