Interface CommandData
-
- All Superinterfaces:
SerializableData
- All Known Subinterfaces:
CommandCreateAction,SlashCommandData
public interface CommandData extends SerializableData
Builder for Application Commands.
Use the factory methods provided byCommandsto create instances of this interface.- See Also:
Commands
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static CommandDatafromCommand(Command command)Converts the providedCommandinto a CommandData instance.static CommandDatafromData(DataObject object)Parses the provided serialization back into an CommandData instance.StringgetName()The current command nameCommand.TypegetType()TheCommand.TypebooleanisDefaultEnabled()Whether this command is available to everyone by default.CommandDatasetDefaultEnabled(boolean enabled)Whether this command is available to everyone by default.CommandDatasetName(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
CommandPrivilegeto 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 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:
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 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:
SlashCommandData.fromData(DataObject),Commands.fromList(Collection)
-
-