Class SubcommandGroupData
- java.lang.Object
-
- net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData
-
- All Implemented Interfaces:
SerializableData
public class SubcommandGroupData extends Object implements SerializableData
Builder for a Slash-Command group.
-
-
Constructor Summary
Constructors Constructor Description SubcommandGroupData(String name, String description)
Create an group builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SubcommandGroupData
addSubcommands(Collection<? extends SubcommandData> subcommands)
Add up to 25Subcommands
to this group.SubcommandGroupData
addSubcommands(SubcommandData... subcommands)
Add up to 25Subcommands
to this group.static SubcommandGroupData
fromData(DataObject json)
Parses the provided serialization back into an SubcommandGroupData instance.String
getDescription()
The description for this subcommand groupString
getName()
The name for this subcommand groupList<SubcommandData>
getSubcommands()
TheSubcommands
in this group.SubcommandGroupData
setDescription(String description)
Configure the descriptionSubcommandGroupData
setName(String name)
Configure the nameDataObject
toData()
SerializedDataObject
for this object.
-
-
-
Constructor Detail
-
SubcommandGroupData
public SubcommandGroupData(@Nonnull String name, @Nonnull String description)
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 Detail
-
setName
@Nonnull public SubcommandGroupData setName(@Nonnull String name)
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
@Nonnull public SubcommandGroupData setDescription(@Nonnull String description)
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
-
getDescription
@Nonnull public String getDescription()
The description for this subcommand group- Returns:
- The description
-
getSubcommands
@Nonnull public List<SubcommandData> getSubcommands()
TheSubcommands
in this group.- Returns:
- Immutable list of
SubcommandData
-
addSubcommands
@Nonnull public SubcommandGroupData addSubcommands(@Nonnull 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 is provided, or more than 25 subcommands 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 is provided, or more than 25 subcommands are provided
-
toData
@Nonnull public DataObject toData()
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-
fromData
@Nonnull public static SubcommandGroupData fromData(@Nonnull DataObject json)
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
-
-