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 CommandDatafromCommand(Command command) Converts the providedCommandinto a CommandData instance.static CommandDatafromData(DataObject object) Parses the provided serialization back into an CommandData instance.Gets theDefaultMemberPermissionsof this command.getName()The current command namegetType()TheCommand.TypebooleanWhether the command can only be used inside a guild.setDefaultPermissions(DefaultMemberPermissions permission) Sets thePermissionsthat a user must have in a specific channel to be able to use this command.setGuildOnly(boolean guildOnly) Sets whether this command is only usable in a guild (Default: false).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
-
setDefaultPermissions
Sets thePermissionsthat a user must have in a specific channel to be able to use this command.
By default, everyone can use this command (DefaultMemberPermissions.ENABLED). Additionally, a command can be disabled for everyone but admins viaDefaultMemberPermissions.DISABLED.These configurations can be overwritten by moderators in each guild. See
Command.retrievePrivileges(net.dv8tion.jda.api.entities.Guild)to get moderator defined overrides.- Parameters:
permission-DefaultMemberPermissionsrepresenting the default permissions of this command.- Returns:
- The builder instance, for chaining
- See Also:
-
setGuildOnly
Sets whether this command is only usable in a guild (Default: false).
This only has an effect if this command is registered globally.- Parameters:
guildOnly- Whether to restrict this command to guilds- Returns:
- The builder instance, for chaining
-
getName
The current command name- Returns:
- The command name
-
getType
TheCommand.Type- Returns:
- The
Command.Type
-
getDefaultPermissions
Gets theDefaultMemberPermissionsof this command.
If no permissions have been set, this returnsDefaultMemberPermissions.ENABLED.- Returns:
- DefaultMemberPermissions of this command.
- See Also:
-
isGuildOnly
boolean isGuildOnly()Whether the command can only be used inside a guild.
Always true for guild commands.- Returns:
- True, if this command is restricted to guilds.
-
fromCommand
Converts the providedCommandinto 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 serializedDataObjectrepresenting 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:
-