Interface CommandEditAction
-
- All Superinterfaces:
RestAction<Command>
public interface CommandEditAction extends RestAction<Command>
SpecializedRestAction
used to edit an existing command.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CommandEditAction
addCheck(java.util.function.BooleanSupplier checks)
Shortcut forsetCheck(() -> getCheck().getAsBoolean() && checks.getAsBoolean())
.default CommandEditAction
addOption(OptionType type, java.lang.String name, java.lang.String description)
Adds an option to this command.default CommandEditAction
addOption(OptionType type, java.lang.String name, java.lang.String description, boolean required)
Adds an option to this command.default CommandEditAction
addOptions(java.util.Collection<? extends OptionData> options)
Adds up to 25 options to this command.CommandEditAction
addOptions(OptionData... options)
Adds up to 25 options to this command.default CommandEditAction
addSubcommandGroups(java.util.Collection<? extends SubcommandGroupData> groups)
Add up to 25Subcommand-Groups
to this command.CommandEditAction
addSubcommandGroups(SubcommandGroupData... groups)
Add up to 25Subcommand-Groups
to this command.default CommandEditAction
addSubcommands(java.util.Collection<? extends SubcommandData> subcommands)
Add up to 25Subcommands
to this command.CommandEditAction
addSubcommands(SubcommandData... subcommands)
Add up to 25Subcommands
to this command.CommandEditAction
apply(CommandData commandData)
Replace the command with the providedCommandData
.CommandEditAction
clearOptions()
Removes all existing options/subcommands/groups from this command.CommandEditAction
deadline(long timestamp)
Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.CommandEditAction
setCheck(java.util.function.BooleanSupplier checks)
Sets the last-second checks before finally executing the http request in the queue.CommandEditAction
setDefaultEnabled(boolean enabled)
Whether this command is available to everyone by default.CommandEditAction
setDescription(java.lang.String description)
Configure the descriptionCommandEditAction
setName(java.lang.String name)
Configure the nameCommandEditAction
timeout(long timeout, java.util.concurrent.TimeUnit unit)
Timeout for this RestAction instance.-
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
and, and, complete, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
-
-
-
Method Detail
-
setCheck
@Nonnull @CheckReturnValue CommandEditAction 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 tofalse
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 interfaceRestAction<Command>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
RestAction.getCheck()
,RestAction.addCheck(BooleanSupplier)
-
addCheck
@Nonnull @CheckReturnValue CommandEditAction addCheck(@Nonnull java.util.function.BooleanSupplier checks)
Description copied from interface:RestAction
Shortcut forsetCheck(() -> getCheck().getAsBoolean() && checks.getAsBoolean())
.- Specified by:
addCheck
in interfaceRestAction<Command>
- Parameters:
checks
- Other checks to run- Returns:
- The current RestAction for chaining convenience
- See Also:
RestAction.setCheck(BooleanSupplier)
-
timeout
@Nonnull @CheckReturnValue CommandEditAction 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 asdeadline(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 interfaceRestAction<Command>
- Parameters:
timeout
- The timeout to useunit
-Unit
for the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
RestAction.setDefaultTimeout(long, TimeUnit)
-
deadline
@Nonnull @CheckReturnValue CommandEditAction deadline(long timestamp)
Description copied from interface:RestAction
Similar toRestAction.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 aTimeoutException
.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 interfaceRestAction<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)
-
apply
@Nonnull @CheckReturnValue CommandEditAction apply(@Nonnull CommandData commandData)
Replace the command with the providedCommandData
.- Parameters:
commandData
- The data for the command- Returns:
- The CommandEditAction instance, for chaining
- Throws:
java.lang.IllegalArgumentException
- If null is provided
-
setDefaultEnabled
@Nonnull @CheckReturnValue CommandEditAction 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 CommandEditAction instance, for chaining
-
setName
@Nonnull @CheckReturnValue CommandEditAction setName(@Nullable java.lang.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:
java.lang.IllegalArgumentException
- If the name is not alphanumeric or not between 1-32 characters
-
setDescription
@Nonnull @CheckReturnValue CommandEditAction setDescription(@Nullable java.lang.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:
java.lang.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
- TheOptions
to add- Returns:
- The CommandEditAction 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
orOptionType.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 java.util.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
- TheOptions
to add- Returns:
- The CommandEditAction 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
orOptionType.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 java.lang.String name, @Nonnull java.lang.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
- TheOptionType
name
- The lowercase option name, 1-32 charactersdescription
- The option description, 1-100 charactersrequired
- Whether this option is required (SeeOptionData.setRequired(boolean)
)- Returns:
- The CommandEditAction 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
orOptionType.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 java.lang.String name, @Nonnull java.lang.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
- TheOptionType
name
- The lowercase option name, 1-32 charactersdescription
- The option description, 1-100 characters- Returns:
- The CommandEditAction 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
orOptionType.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 25Subcommands
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:
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.
-
addSubcommands
@Nonnull @CheckReturnValue default CommandEditAction addSubcommands(@Nonnull java.util.Collection<? extends SubcommandData> subcommands)
Add up to 25Subcommands
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:
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 CommandEditAction addSubcommandGroups(@Nonnull SubcommandGroupData... groups)
Add up to 25Subcommand-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:
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.
-
addSubcommandGroups
@Nonnull @CheckReturnValue default CommandEditAction addSubcommandGroups(@Nonnull java.util.Collection<? extends SubcommandGroupData> groups)
Add up to 25Subcommand-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:
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.
-
-