Interface CommandCreateAction

  • All Superinterfaces:
    RestAction<Command>

    public interface CommandCreateAction
    extends RestAction<Command>
    Specialized RestAction used to create or update commands.
    If a command with the specified name already exists, it will be replaced!
    • Method Detail

      • setCheck

        @Nonnull
        CommandCreateAction setCheck​(@Nullable
                                     java.util.function.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:
        RestAction.getCheck(), RestAction.addCheck(BooleanSupplier)
      • timeout

        @Nonnull
        CommandCreateAction timeout​(long timeout,
                                    @Nonnull
                                    java.util.concurrent.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:
        RestAction.setDefaultTimeout(long, TimeUnit)
      • deadline

        @Nonnull
        CommandCreateAction 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:
        RestAction.timeout(long, TimeUnit), RestAction.setDefaultTimeout(long, TimeUnit)
      • setDefaultEnabled

        @Nonnull
        @CheckReturnValue
        CommandCreateAction 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.
        Parameters:
        enabled - True, if this command is enabled by default for everyone. (Default: true)
        Returns:
        The CommandCreateAction instance, for chaining
      • setName

        @Nonnull
        @CheckReturnValue
        CommandCreateAction setName​(@Nonnull
                                    java.lang.String name)
        Change the name of the command to the provided name.
        Parameters:
        name - The lowercase alphanumeric (with dash) name, 1-32 characters
        Returns:
        The CommandCreateAction instance, for chaining
        Throws:
        java.lang.IllegalArgumentException - If the name is null, not alphanumeric, or not between 1-32 characters
      • setDescription

        @Nonnull
        @CheckReturnValue
        CommandCreateAction setDescription​(@Nonnull
                                           java.lang.String description)
        Change the description of the command.
        This is visible to the user in the client and should give a meaningful description of this command.
        Parameters:
        description - The description, 1-100 characters
        Returns:
        The CommandCreateAction instance, for chaining
        Throws:
        java.lang.IllegalArgumentException - If the name is not lowercase, alphanumeric (with dash), or 1-32 characters long
      • addOptions

        @Nonnull
        @CheckReturnValue
        CommandCreateAction addOptions​(@Nonnull
                                       OptionData... options)
        Add up to 25 options to this command.

        Required options must be added before non-required options!

        Parameters:
        options - The options to add
        Returns:
        The CommandCreateAction instance, for chaining
        Throws:
        java.lang.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 CommandCreateAction addOptions​(@Nonnull
                                               java.util.Collection<? extends OptionData> options)
        Add up to 25 options to this command.

        Required options must be added before non-required options!

        Parameters:
        options - The options to add
        Returns:
        The CommandCreateAction instance, for chaining
        Throws:
        java.lang.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 CommandCreateAction addOption​(@Nonnull
                                              OptionType type,
                                              @Nonnull
                                              java.lang.String name,
                                              @Nonnull
                                              java.lang.String description,
                                              boolean required)
        Add one option to this 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 CommandCreateAction instance, for chaining
        Throws:
        java.lang.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 CommandCreateAction addOption​(@Nonnull
                                              OptionType type,
                                              @Nonnull
                                              java.lang.String name,
                                              @Nonnull
                                              java.lang.String description)
        Add one option to this command.
        The option is set to be non-required! You can use addOption(OptionType, String, String, boolean) to add a required option instead.

        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 CommandCreateAction instance, for chaining
        Throws:
        java.lang.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
        CommandCreateAction addSubcommands​(@Nonnull
                                           SubcommandData subcommands)
        Add up to 25 Subcommands to this command.
        Parameters:
        subcommands - The subcommands to add
        Returns:
        The CommandCreateAction instance, for chaining
        Throws:
        java.lang.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
        CommandCreateAction addSubcommandGroups​(@Nonnull
                                                SubcommandGroupData groups)
        Add up to 25 Subcommand-Groups to this command.
        Parameters:
        groups - The subcommand groups to add
        Returns:
        The CommandCreateAction instance, for chaining
        Throws:
        java.lang.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.