Interface Command
-
- All Superinterfaces:
ISnowflake
public interface Command extends ISnowflake
Represents a Discord slash-command.
This can be used to edit or delete the command.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classCommand.ChoicePredefined choice used for options.static classCommand.OptionAn Option for a command.static classCommand.SubcommandAn Subcommand for a command.static classCommand.SubcommandGroupAn Subcommand Group for a command.static classCommand.TypePossible command types
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description RestAction<Void>delete()Delete this command.CommandEditActioneditCommand()Edit this command.default StringgetApplicationId()The id of the application this command belongs to.longgetApplicationIdLong()The id of the application this command belongs to.StringgetDescription()The description of this command.JDAgetJDA()Returns theJDAinstance of this CommandStringgetName()The name of this command.List<Command.Option>getOptions()TheOptionsof this command.List<Command.SubcommandGroup>getSubcommandGroups()TheSubcommandGroupsof this command.List<Command.Subcommand>getSubcommands()TheSubcommandsof this command.default OffsetDateTimegetTimeModified()The time this command was updated last.Command.TypegetType()TheCommand.Typeof commandlonggetVersion()The version of this command.booleanisDefaultEnabled()Whether this command is enabled for everyone by default.RestAction<List<CommandPrivilege>>retrievePrivileges(Guild guild)Retrieves theCommandPrivilegesfor this command.RestAction<List<CommandPrivilege>>updatePrivileges(Guild guild, Collection<? extends CommandPrivilege> privileges)Updates the list ofCommandPrivilegesfor this command.RestAction<List<CommandPrivilege>>updatePrivileges(Guild guild, CommandPrivilege... privileges)Updates the list ofCommandPrivilegesfor this command.-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Method Detail
-
delete
@Nonnull @CheckReturnValue RestAction<Void> delete()
Delete this command.
If this is a global command it may take up to 1 hour to vanish from all clients.- Returns:
RestAction- Throws:
IllegalStateException- If this command is not owned by this bot
-
editCommand
@Nonnull @CheckReturnValue CommandEditAction editCommand()
Edit this command.
This can be used to change the command attributes such as name or description.- Returns:
CommandEditAction- Throws:
IllegalStateException- If this command is not owned by this bot
-
retrievePrivileges
@Nonnull @CheckReturnValue RestAction<List<CommandPrivilege>> retrievePrivileges(@Nonnull Guild guild)
Retrieves theCommandPrivilegesfor this command.
This is a shortcut forGuild.retrieveCommandPrivilegesById(String).These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND- Parameters:
guild- The target guild from which to retrieve the privileges- Returns:
RestAction- Type:ListofCommandPrivilege- Throws:
IllegalArgumentException- If the guild is null
-
updatePrivileges
@Nonnull @CheckReturnValue RestAction<List<CommandPrivilege>> updatePrivileges(@Nonnull Guild guild, @Nonnull Collection<? extends CommandPrivilege> privileges)
Updates the list ofCommandPrivilegesfor this command.
Note that commands are enabled by default for all members of a guild, which means you can only blacklist roles and members using this method. To change this behavior, useCommandData.setDefaultEnabled(boolean)on your command.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND- Parameters:
guild- The target guild from which to update the privilegesprivileges- Complete list ofCommandPrivilegesfor this command- Returns:
RestAction- Type:ListorCommandPrivilegeThe updated list of privileges for this command.- Throws:
IllegalArgumentException- If null is providedIllegalStateException- If this command is not owned by this bot
-
updatePrivileges
@Nonnull @CheckReturnValue RestAction<List<CommandPrivilege>> updatePrivileges(@Nonnull Guild guild, @Nonnull CommandPrivilege... privileges)
Updates the list ofCommandPrivilegesfor this command.
Note that commands are enabled by default for all members of a guild, which means you can only blacklist roles and members using this method. To change this behavior, useCommandData.setDefaultEnabled(boolean)on your command.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND- Parameters:
guild- The target guild from which to update the privilegesprivileges- Complete list ofCommandPrivilegesfor this command- Returns:
RestAction- Type:ListorCommandPrivilegeThe updated list of privileges for this command.- Throws:
IllegalArgumentException- If null is providedIllegalStateException- If this command is not owned by this bot
-
getJDA
@Nonnull JDA getJDA()
Returns theJDAinstance of this Command- Returns:
- the corresponding JDA instance
-
getType
@Nonnull Command.Type getType()
TheCommand.Typeof command- Returns:
- The command type
-
getDescription
@Nonnull String getDescription()
The description of this command.- Returns:
- The description, empty for context menu commands
-
isDefaultEnabled
boolean isDefaultEnabled()
Whether this command is enabled for everyone by default.- Returns:
- True, if everyone can use this command by default.
-
getOptions
@Nonnull List<Command.Option> getOptions()
TheOptionsof this command.- Returns:
- Immutable list of command options
-
getSubcommands
@Nonnull List<Command.Subcommand> getSubcommands()
TheSubcommandsof this command.- Returns:
- Immutable list of subcommands
-
getSubcommandGroups
@Nonnull List<Command.SubcommandGroup> getSubcommandGroups()
TheSubcommandGroupsof this command.- Returns:
- Immutable list of subcommand groups
-
getApplicationIdLong
long getApplicationIdLong()
The id of the application this command belongs to.- Returns:
- The application id
-
getApplicationId
@Nonnull default String getApplicationId()
The id of the application this command belongs to.- Returns:
- The application id
-
getVersion
long getVersion()
The version of this command.
This changes when a command is updated throughupsertCommand,updateCommands, oreditCommandById
Useful for checking if command cache is outdated- Returns:
- The version of the command as a snowflake id.
- See Also:
getTimeModified()
-
getTimeModified
@Nonnull default OffsetDateTime getTimeModified()
The time this command was updated last.- Returns:
- Time this command was updated last.
- See Also:
getVersion()
-
-