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
ConstructorsConstructorDescriptionSubcommandGroupData(String name, String description) Create an group builder. -
Method Summary
Modifier and TypeMethodDescriptionaddSubcommands(Collection<? extends SubcommandData> subcommands) Add up to 25Subcommandsto this group.addSubcommands(SubcommandData... subcommands) Add up to 25Subcommandsto this group.static SubcommandGroupDatafromData(DataObject json) Parses the provided serialization back into an SubcommandGroupData instance.static SubcommandGroupDatafromGroup(Command.SubcommandGroup group) Converts the providedCommand.SubcommandGroupinto a SubcommandGroupData instance.The description for this subcommand groupThe localizations of this subcommand's description forvarious languagesgroup.getName()The name for this subcommand groupThe localizations of this subcommand's name forvarious languagesgroup.@Unmodifiable List<SubcommandData> TheSubcommandsin this group.booleanremoveSubcommand(Predicate<? super SubcommandData> condition) Removes all subcommands that evaluate totrueunder the providedcondition.booleanremoveSubcommandByName(String name) Removes subcommands by the provided name.setDescription(String description) Configure the descriptionsetDescriptionLocalization(DiscordLocale locale, String description) Sets alanguage-specificlocalization of this subcommand group's description.Sets multiplelanguage-specificlocalizations of this subcommand group's description.Configure the namesetNameLocalization(DiscordLocale locale, String name) Sets alanguage-specificlocalization of this subcommand group's name.Sets multiplelanguage-specificlocalizations of this subcommand group's name.toData()SerializedDataObjectfor 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-specificlocalization 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-specificlocalizations 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.UNKNOWNkey - 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-specificlocalization 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-specificlocalizations 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.UNKNOWNkey - 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 languagesgroup.- Returns:
- The
LocalizationMapcontaining the mapping fromDiscordLocaleto the localized name
-
getDescription
The description for this subcommand group- Returns:
- The description
-
getDescriptionLocalizations
The localizations of this subcommand's description forvarious languagesgroup.- Returns:
- The
LocalizationMapcontaining the mapping fromDiscordLocaleto the localized description
-
removeSubcommand
Removes all subcommands that evaluate totrueunder 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
TheSubcommandsin this group.- Returns:
- Immutable list of
SubcommandData
-
addSubcommands
Add up to 25Subcommandsto 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 25Subcommandsto 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:SerializableDataSerializedDataObjectfor this object.- Specified by:
toDatain interfaceSerializableData- Returns:
DataObject
-
fromData
Parses the provided serialization back into an SubcommandGroupData instance.
This is the reverse function fortoData().- Parameters:
json- The serializedDataObjectrepresenting 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.SubcommandGroupinto 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
-