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 groupgetName()
The name for this subcommand groupTheSubcommands
in this group.setDescription
(String description) Configure the descriptionConfigure the nametoData()
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
-
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
-
getName
The name for this subcommand group- Returns:
- The name
-
getDescription
The description for this subcommand group- Returns:
- The description
-
getSubcommands
TheSubcommands
in this group.
These subcommand instances are reconstructed, which means that any modifications will not be reflected in the backing state.- 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
-