Interface CommandData
- All Superinterfaces:
SerializableData
- All Known Subinterfaces:
CommandCreateAction
,SlashCommandData
Builder for Application Commands.
Use the factory methods provided by
Use the factory methods provided by
Commands
to create instances of this interface.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic CommandData
fromCommand
(Command command) Converts the providedCommand
into a CommandData instance.static CommandData
fromData
(DataObject object) Parses the provided serialization back into an CommandData instance.getName()
The current command namegetType()
TheCommand.Type
boolean
Whether this command is available to everyone by default.setDefaultEnabled
(boolean enabled) Whether this command is available to everyone by default.Configure the command name.Methods inherited from interface net.dv8tion.jda.api.utils.data.SerializableData
toData
-
Method Details
-
setName
Configure the command name.- Parameters:
name
- The name, 1-32 characters (lowercase and alphanumeric forCommand.Type.SLASH
)- Returns:
- The builder instance, for chaining
- Throws:
IllegalArgumentException
- If the name is not between 1-32 characters long, or not lowercase and alphanumeric for slash commands
-
setDefaultEnabled
Whether this command is available to everyone by default.
If this is disabled, you need to explicitly whitelist users and roles per guild.You can use
CommandPrivilege
to enable or disable this command per guild for roles and members of the guild. SeeCommand.updatePrivileges(Guild, CommandPrivilege...)
andGuild.updateCommandPrivileges(Map)
.- Parameters:
enabled
- True, if this command is enabled by default for everyone. (Default: true)- Returns:
- The builder instance, for chaining
-
getName
The current command name- Returns:
- The command name
-
isDefaultEnabled
boolean isDefaultEnabled()Whether this command is available to everyone by default.- Returns:
- True, if this command is enabled to everyone by default
- See Also:
-
getType
TheCommand.Type
- Returns:
- The
Command.Type
-
fromCommand
Converts the providedCommand
into a CommandData instance.- Parameters:
command
- The command to convert- Returns:
- An instance of CommandData
- Throws:
IllegalArgumentException
- If null is provided or the command has illegal configuration- See Also:
-
fromData
Parses the provided serialization back into an CommandData instance.
This is the reverse function forSerializableData.toData()
.- Parameters:
object
- The serializedDataObject
representing the command- Returns:
- The parsed CommandData 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- See Also:
-