Class Commands
java.lang.Object
net.dv8tion.jda.api.interactions.commands.build.Commands
Provides various static factory methods for building commands of different types.
This also includes context menu items.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Maximum amount of global or guild message context commandsstatic final int
Maximum amount of global or guild slash commandsstatic final int
Maximum amount of global or guild user context commands -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CommandData
context
(Command.Type type, String name) Create a context menu command builder for the specified command type.static List
<CommandData> fromList
(Collection<? extends DataObject> collection) Parses the provided serialization back into an CommandData instance.static List
<CommandData> Parses the provided serialization back into an CommandData instance.static CommandData
Create a message context menu command builder.static SlashCommandData
Create a slash command builder.static CommandData
Create a user context menu command builder.
-
Field Details
-
MAX_SLASH_COMMANDS
public static final int MAX_SLASH_COMMANDSMaximum amount of global or guild slash commands- See Also:
-
MAX_USER_COMMANDS
public static final int MAX_USER_COMMANDSMaximum amount of global or guild user context commands- See Also:
-
MAX_MESSAGE_COMMANDS
public static final int MAX_MESSAGE_COMMANDSMaximum amount of global or guild message context commands- See Also:
-
-
Constructor Details
-
Commands
public Commands()
-
-
Method Details
-
slash
Create a slash command builder.- Parameters:
name
- The command name, 1-32 lowercase alphanumeric charactersdescription
- The command description, 1-100 characters- Returns:
SlashCommandData
builder for slash commands- 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
-
message
Create a message context menu command builder.- Parameters:
name
- The command name, 1-32 characters- Returns:
CommandData
- Throws:
IllegalArgumentException
- If the name is not between 1-32 characters long
-
user
Create a user context menu command builder.- Parameters:
name
- The command name, 1-32 characters- Returns:
CommandData
- Throws:
IllegalArgumentException
- If the name is not between 1-32 characters long
-
context
Create a context menu command builder for the specified command type.
This cannot be used for slash commands, because they require a description. Useslash(String, String)
to create a slash command.- Parameters:
type
- The command type, must not beSLASH
name
- The command name, 1-32 characters- Returns:
CommandData
- Throws:
IllegalArgumentException
- If the name is not between 1-32 characters long, the type isCommand.Type.SLASH
, or the type is null.
-
fromList
Parses the provided serialization back into an CommandData instance.
This is the reverse function forSerializableData.toData()
.- Parameters:
array
- Array of serializedDataObject
representing the commands- Returns:
- The parsed CommandData instances, 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- See Also:
-
fromList
@Nonnull public static List<CommandData> fromList(@Nonnull Collection<? extends DataObject> collection) Parses the provided serialization back into an CommandData instance.
This is the reverse function forSerializableData.toData()
.- Parameters:
collection
- Collection of serializedDataObject
representing the commands- Returns:
- The parsed CommandData instances, 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- See Also:
-