Class SubcommandGroupData
java.lang.Object
net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData
- All Implemented Interfaces:
SerializableData
Builder for a Slash-Command group.
-
Constructor Summary
ConstructorDescriptionSubcommandGroupData
(String name, String description) Create an group builder. -
Method Summary
Modifier and TypeMethodDescriptionaddSubcommands
(Collection<? extends SubcommandData> subcommands) Add up to 25Subcommands
to this group.addSubcommands
(SubcommandData... subcommands) Add up to 25Subcommands
to this group.static SubcommandGroupData
fromData
(DataObject json) Parses the provided serialization back into an SubcommandGroupData instance.static SubcommandGroupData
fromGroup
(Command.SubcommandGroup group) Converts the providedCommand.SubcommandGroup
into a SubcommandGroupData instance.The description for this subcommand groupThe localizations of this subcommand's description forvarious languages
group.getName()
The name for this subcommand groupThe localizations of this subcommand's name forvarious languages
group.@Unmodifiable List
<SubcommandData> TheSubcommands
in this group.boolean
removeSubcommand
(Predicate<? super SubcommandData> condition) Removes all subcommands that evaluate totrue
under the providedcondition
.boolean
removeSubcommandByName
(String name) Removes subcommands by the provided name.setDescription
(String description) Configure the descriptionsetDescriptionLocalization
(DiscordLocale locale, String description) Sets alanguage-specific
localization of this subcommand group's description.Sets multiplelanguage-specific
localizations of this subcommand group's description.Configure the namesetNameLocalization
(DiscordLocale locale, String name) Sets alanguage-specific
localization of this subcommand group's name.Sets multiplelanguage-specific
localizations of this subcommand group's name.toData()
SerializedDataObject
for this object.
-
Constructor Details
-
SubcommandGroupData
Create an group builder.- Parameters:
name
- The group name, 1-32 lowercase alphanumeric charactersdescription
- The group description, 1-100 characters- Throws:
IllegalArgumentException
- If any of the following requirements are not met- The name must be lowercase alphanumeric (with dash), 1-32 characters long
- The description must be 1-100 characters long
-
-
Method Details
-
setName
Configure the name- Parameters:
name
- The lowercase alphanumeric (with dash) name, 1-32 characters- Returns:
- The SubcommandGroupData instance, for chaining
- Throws:
IllegalArgumentException
- If the name is null, not alphanumeric, or not between 1-32 characters
-
setNameLocalization
@Nonnull public SubcommandGroupData setNameLocalization(@Nonnull DiscordLocale locale, @Nonnull String name) Sets alanguage-specific
localization of this subcommand group's name.- Parameters:
locale
- The locale to associate the translated name withname
- The translated name to put- Returns:
- This builder instance, for chaining
- Throws:
IllegalArgumentException
-- If the locale is null
- If the name is null
- If the locale is
DiscordLocale.UNKNOWN
- If the name does not pass the corresponding
name check
-
setNameLocalizations
Sets multiplelanguage-specific
localizations of this subcommand group's name.- Parameters:
map
- The map from which to transfer the translated names- Returns:
- This builder instance, for chaining
- Throws:
IllegalArgumentException
-- If the map is null
- If the map contains an
DiscordLocale.UNKNOWN
key - If the map contains a name which does not pass the corresponding
name check
-
setDescription
Configure the description- Parameters:
description
- The description, 1-100 characters- Returns:
- The SubcommandGroupData instance, for chaining
- Throws:
IllegalArgumentException
- If the name is null or not between 1-100 characters
-
setDescriptionLocalization
@Nonnull public SubcommandGroupData setDescriptionLocalization(@Nonnull DiscordLocale locale, @Nonnull String description) Sets alanguage-specific
localization of this subcommand group's description.- Parameters:
locale
- The locale to associate the translated description withdescription
- The translated description to put- Returns:
- This builder instance, for chaining
- Throws:
IllegalArgumentException
-- If the locale is null
- If the description is null
- If the locale is
DiscordLocale.UNKNOWN
- If the description does not pass the corresponding
description check
-
setDescriptionLocalizations
@Nonnull public SubcommandGroupData setDescriptionLocalizations(@Nonnull Map<DiscordLocale, String> map) Sets multiplelanguage-specific
localizations of this subcommand group's description.- Parameters:
map
- The map from which to transfer the translated descriptions- Returns:
- This builder instance, for chaining
- Throws:
IllegalArgumentException
-- If the map is null
- If the map contains an
DiscordLocale.UNKNOWN
key - If the map contains a description which does not pass the corresponding
description check
-
getName
The name for this subcommand group- Returns:
- The name
-
getNameLocalizations
The localizations of this subcommand's name forvarious languages
group.- Returns:
- The
LocalizationMap
containing the mapping fromDiscordLocale
to the localized name
-
getDescription
The description for this subcommand group- Returns:
- The description
-
getDescriptionLocalizations
The localizations of this subcommand's description forvarious languages
group.- Returns:
- The
LocalizationMap
containing the mapping fromDiscordLocale
to the localized description
-
removeSubcommand
Removes all subcommands that evaluate totrue
under the providedcondition
.Example: Remove all subcommands
command.removeSubcommands(subcommand -> true);
- Parameters:
condition
- The removal condition (must not throw)- Returns:
- True, if any subcommands were removed
- Throws:
IllegalArgumentException
- If the condition is null
-
removeSubcommandByName
Removes subcommands by the provided name.- Parameters:
name
- The case-sensitive subcommand name- Returns:
- True, if any subcommands were removed
-
getSubcommands
TheSubcommands
in this group.- Returns:
- Immutable list of
SubcommandData
-
addSubcommands
Add up to 25Subcommands
to this group.- Parameters:
subcommands
- The subcommands to add- Returns:
- The SubcommandGroupData instance, for chaining
- Throws:
IllegalArgumentException
- If null, more than 25 subcommands, or duplicate subcommand names are provided.
-
addSubcommands
@Nonnull public SubcommandGroupData addSubcommands(@Nonnull Collection<? extends SubcommandData> subcommands) Add up to 25Subcommands
to this group.- Parameters:
subcommands
- The subcommands to add- Returns:
- The SubcommandGroupData instance, for chaining
- Throws:
IllegalArgumentException
- If null, more than 25 subcommands, or duplicate subcommand names are provided.
-
toData
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-
fromData
Parses the provided serialization back into an SubcommandGroupData instance.
This is the reverse function fortoData()
.- Parameters:
json
- The serializedDataObject
representing the group- Returns:
- The parsed SubcommandGroupData instance, which can be further configured through setters
- Throws:
ParsingException
- If the serialized object is missing required fieldsIllegalArgumentException
- If any of the values are failing the respective checks such as length
-
fromGroup
Converts the providedCommand.SubcommandGroup
into a SubcommandGroupData instance.- Parameters:
group
- The subcommand group to convert- Returns:
- An instance of SubcommandGroupData
- Throws:
IllegalArgumentException
- If null is provided or the subcommand group has illegal configuration
-