Interface CommandEditAction

All Superinterfaces:
RestAction<Command>

public interface CommandEditAction extends RestAction<Command>
Specialized RestAction used to edit an existing command.
  • Method Details

    • setCheck

      @Nonnull @CheckReturnValue CommandEditAction setCheck(@Nullable BooleanSupplier checks)
      Description copied from interface: RestAction
      Sets the last-second checks before finally executing the http request in the queue.
      If the provided supplier evaluates to false or throws an exception this will not be finished. When an exception is thrown from the supplier it will be provided to the failure callback.
      Specified by:
      setCheck in interface RestAction<Command>
      Parameters:
      checks - The checks to run before executing the request, or null to run no checks
      Returns:
      The current RestAction for chaining convenience
      See Also:
    • addCheck

      @Nonnull @CheckReturnValue CommandEditAction addCheck(@Nonnull BooleanSupplier checks)
      Description copied from interface: RestAction
      Shortcut for setCheck(() -> getCheck().getAsBoolean() && checks.getAsBoolean()).
      Specified by:
      addCheck in interface RestAction<Command>
      Parameters:
      checks - Other checks to run
      Returns:
      The current RestAction for chaining convenience
      See Also:
    • timeout

      @Nonnull @CheckReturnValue CommandEditAction timeout(long timeout, @Nonnull TimeUnit unit)
      Description copied from interface: RestAction
      Timeout for this RestAction instance.
      If the request doesn't get executed within the timeout it will fail.

      When a RestAction times out, it will fail with a TimeoutException. This is the same as deadline(System.currentTimeMillis() + unit.toMillis(timeout)).

      Example

      action.timeout(10, TimeUnit.SECONDS) // 10 seconds from now
            .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
      
      Specified by:
      timeout in interface RestAction<Command>
      Parameters:
      timeout - The timeout to use
      unit - Unit for the timeout value
      Returns:
      The same RestAction instance with the applied timeout
      See Also:
    • deadline

      @Nonnull @CheckReturnValue CommandEditAction deadline(long timestamp)
      Description copied from interface: RestAction
      Similar to RestAction.timeout(long, TimeUnit) but schedules a deadline at which the request has to be completed.
      If the deadline is reached, the request will fail with a TimeoutException.

      This does not mean that the request will immediately timeout when the deadline is reached. JDA will check the deadline right before executing the request or within intervals in a worker thread. This only means the request will timeout if the deadline has passed.

      Example

      action.deadline(System.currentTimeMillis() + 10000) // 10 seconds from now
            .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
      
      Specified by:
      deadline in interface RestAction<Command>
      Parameters:
      timestamp - Millisecond timestamp at which the request will timeout
      Returns:
      The same RestAction with the applied deadline
      See Also:
    • apply

      @Nonnull @CheckReturnValue CommandEditAction apply(@Nonnull CommandData commandData)
      Replace the command with the provided CommandData.
      Parameters:
      commandData - The data for the command
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException - If null is provided
      See Also:
    • setName

      @Nonnull @CheckReturnValue CommandEditAction setName(@Nullable String name)
      Configure the name
      Parameters:
      name - The lowercase alphanumeric (with dash) name, 1-32 characters. Use null to keep the current name.
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException - If the name is not alphanumeric or not between 1-32 characters
    • setContexts

      @Nonnull @CheckReturnValue default CommandEditAction setContexts(@Nonnull InteractionContextType... contexts)
      Sets the contexts in which this command can be executed (Default: Guild and Bot DMs).
      This only has an effect if this command is registered globally.
      Parameters:
      contexts - The contexts in which this command can be executed
      Returns:
      The builder instance, for chaining
      Throws:
      IllegalArgumentException - If null or no interaction context types were passed
    • setContexts

      @Nonnull @CheckReturnValue CommandEditAction setContexts(@Nonnull Collection<InteractionContextType> contexts)
      Sets the contexts in which this command can be executed (Default: Guild and Bot DMs).
      This only has an effect if this command is registered globally.
      Parameters:
      contexts - The contexts in which this command can be executed
      Returns:
      The builder instance, for chaining
      Throws:
      IllegalArgumentException - If null or no interaction context types were passed
    • setIntegrationTypes

      @Nonnull @CheckReturnValue default CommandEditAction setIntegrationTypes(@Nonnull IntegrationType... integrationTypes)
      Sets the integration types on which this command can be installed on (Default: Guilds).
      This only has an effect if this command is registered globally.
      Parameters:
      integrationTypes - The integration types on which this command can be installed on
      Returns:
      The builder instance, for chaining
      Throws:
      IllegalArgumentException - If null or no integration types were passed
    • setIntegrationTypes

      @Nonnull @CheckReturnValue CommandEditAction setIntegrationTypes(@Nonnull Collection<IntegrationType> integrationTypes)
      Sets the integration types on which this command can be installed on (Default: Guilds).
      This only has an effect if this command is registered globally.
      Parameters:
      integrationTypes - The integration types on which this command can be installed on
      Returns:
      The builder instance, for chaining
      Throws:
      IllegalArgumentException - If null or no integration types were passed
    • setNSFW

      @Nonnull @CheckReturnValue CommandEditAction setNSFW(boolean nsfw)
      Sets whether this command should only be usable in NSFW (age-restricted) channels.
      Default: false

      Note: Age-restricted commands will not show up in direct messages by default unless the user enables them in their settings.

      Parameters:
      nsfw - True, to make this command nsfw
      Returns:
      The CommandEditAction instance, for chaining
      See Also:
    • setDefaultPermissions

      @Nonnull @CheckReturnValue CommandEditAction setDefaultPermissions(@Nonnull DefaultMemberPermissions permission)
      Sets the Permissions that 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 via DefaultMemberPermissions.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 - DefaultMemberPermissions representing the default permissions of this command.
      Returns:
      The CommandEditAction instance, for chaining
      See Also:
    • setDescription

      @Nonnull @CheckReturnValue CommandEditAction setDescription(@Nullable String description)
      Configure the description
      Parameters:
      description - The description, 1-100 characters. Use null to keep the current description.
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException - If the name is null or not between 1-100 characters
    • clearOptions

      @Nonnull @CheckReturnValue CommandEditAction clearOptions()
      Removes all existing options/subcommands/groups from this command.
      Returns:
      The CommandEditAction instance, for chaining
    • addOptions

      @Nonnull @CheckReturnValue CommandEditAction addOptions(@Nonnull OptionData... options)
      Adds up to 25 options to this command.
      This will replace any existing options/subcommands/groups on the command.

      Required options must be added before non-required options!

      Parameters:
      options - The Options to add
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException -
      • If you try to mix subcommands/options/groups in one command.
      • If the option type is OptionType.SUB_COMMAND or OptionType.SUB_COMMAND_GROUP.
      • If this option is required and you already added a non-required option.
      • If more than 25 options are provided.
      • If null is provided
    • addOptions

      @Nonnull @CheckReturnValue default CommandEditAction addOptions(@Nonnull Collection<? extends OptionData> options)
      Adds up to 25 options to this command.
      This will replace any existing options/subcommands/groups on the command.

      Required options must be added before non-required options!

      Parameters:
      options - The Options to add
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException -
      • If you try to mix subcommands/options/groups in one command.
      • If the option type is OptionType.SUB_COMMAND or OptionType.SUB_COMMAND_GROUP.
      • If this option is required and you already added a non-required option.
      • If more than 25 options are provided.
      • If null is provided
    • addOption

      @Nonnull @CheckReturnValue default CommandEditAction addOption(@Nonnull OptionType type, @Nonnull String name, @Nonnull String description, boolean required)
      Adds an option to this command.
      This will replace any existing options/subcommands/groups on the command.

      Required options must be added before non-required options!

      Parameters:
      type - The OptionType
      name - The lowercase option name, 1-32 characters
      description - The option description, 1-100 characters
      required - Whether this option is required (See OptionData.setRequired(boolean))
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException -
      • If you try to mix subcommands/options/groups in one command.
      • If the option type is OptionType.SUB_COMMAND or OptionType.SUB_COMMAND_GROUP.
      • If this option is required and you already added a non-required option.
      • If more than 25 options are provided.
      • If null is provided
    • addOption

      @Nonnull @CheckReturnValue default CommandEditAction addOption(@Nonnull OptionType type, @Nonnull String name, @Nonnull String description)
      Adds an option to this command.
      This will replace any existing options/subcommands/groups on the command.

      Required options must be added before non-required options!

      Parameters:
      type - The OptionType
      name - The lowercase option name, 1-32 characters
      description - The option description, 1-100 characters
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException -
      • If you try to mix subcommands/options/groups in one command.
      • If the option type is OptionType.SUB_COMMAND or OptionType.SUB_COMMAND_GROUP.
      • If this option is required and you already added a non-required option.
      • If more than 25 options are provided.
      • If null is provided
    • addSubcommands

      @Nonnull @CheckReturnValue CommandEditAction addSubcommands(@Nonnull SubcommandData... subcommands)
      Add up to 25 Subcommands to this command.
      This will replace any existing options/subcommands/groups on the command.
      Parameters:
      subcommands - The subcommands to add
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException - If null is provided, or more than 25 subcommands are provided. Also throws if you try to mix subcommands/options/groups in one command.
    • addSubcommands

      @Nonnull @CheckReturnValue default CommandEditAction addSubcommands(@Nonnull Collection<? extends SubcommandData> subcommands)
      Add up to 25 Subcommands to this command.
      This will replace any existing options/subcommands/groups on the command.
      Parameters:
      subcommands - The subcommands to add
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException - If null is provided, or more than 25 subcommands are provided. Also throws if you try to mix subcommands/options/groups in one command.
    • addSubcommandGroups

      @Nonnull @CheckReturnValue CommandEditAction addSubcommandGroups(@Nonnull SubcommandGroupData... groups)
      Add up to 25 Subcommand-Groups to this command.
      This will replace any existing options/subcommands/groups on the command.
      Parameters:
      groups - The subcommand groups to add
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException - If null is provided, or more than 25 subcommand groups are provided. Also throws if you try to mix subcommands/options/groups in one command.
    • addSubcommandGroups

      @Nonnull @CheckReturnValue default CommandEditAction addSubcommandGroups(@Nonnull Collection<? extends SubcommandGroupData> groups)
      Add up to 25 Subcommand-Groups to this command.
      This will replace any existing options/subcommands/groups on the command.
      Parameters:
      groups - The subcommand groups to add
      Returns:
      The CommandEditAction instance, for chaining
      Throws:
      IllegalArgumentException - If null is provided, or more than 25 subcommand groups are provided. Also throws if you try to mix subcommands/options/groups in one command.