Interface CommandData
-
- All Superinterfaces:
SerializableData
- All Known Subinterfaces:
CommandCreateAction
,SlashCommandData
public interface CommandData extends SerializableData
Builder for Application Commands.
Use the factory methods provided byCommands
to create instances of this interface.- See Also:
Commands
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static 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.String
getName()
The current command nameCommand.Type
getType()
TheCommand.Type
boolean
isDefaultEnabled()
Whether this command is available to everyone by default.CommandData
setDefaultEnabled(boolean enabled)
Whether this command is available to everyone by default.CommandData
setName(String name)
Configure the command name.-
Methods inherited from interface net.dv8tion.jda.api.utils.data.SerializableData
toData
-
-
-
-
Method Detail
-
setName
@Nonnull CommandData setName(@Nonnull String name)
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
@Nonnull CommandData setDefaultEnabled(boolean enabled)
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
-
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:
setDefaultEnabled(boolean)
,CommandPrivilege
-
getType
@Nonnull Command.Type getType()
TheCommand.Type
- Returns:
- The
Command.Type
-
fromCommand
@Nonnull static CommandData fromCommand(@Nonnull Command command)
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:
SlashCommandData.fromCommand(Command)
-
fromData
@Nonnull static CommandData fromData(@Nonnull DataObject object)
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:
SlashCommandData.fromData(DataObject)
,Commands.fromList(Collection)
-
-