Interface CommandCreateAction
- All Superinterfaces:
CommandData,RestAction<Command>,SerializableData,SlashCommandData
RestAction used to create or update commands.
If a command with the specified name already exists, it will be replaced!
This operation is not idempotent! Commands will persist between restarts of your bot, you only have to create a command once.
-
Method Summary
Modifier and TypeMethodDescriptionaddCheck(BooleanSupplier checks) Shortcut forsetCheck(() -> getCheck().getAsBoolean() && checks.getAsBoolean()).default CommandCreateActionaddOption(OptionType type, String name, String description) Adds an option to this command.default CommandCreateActionaddOption(OptionType type, String name, String description, boolean required) Adds an option to this command.default CommandCreateActionaddOption(OptionType type, String name, String description, boolean required, boolean autoComplete) Adds an option to this command.default CommandCreateActionaddOptions(Collection<? extends OptionData> options) Adds up to 25 options to this command.addOptions(OptionData... options) Adds up to 25 options to this command.default CommandCreateActionaddSubcommandGroups(Collection<? extends SubcommandGroupData> groups) Add up to 25Subcommand-Groupsto this command.addSubcommandGroups(SubcommandGroupData... groups) Add up to 25Subcommand-Groupsto this command.default CommandCreateActionaddSubcommands(Collection<? extends SubcommandData> subcommands) Add up to 25Subcommandsto this command.addSubcommands(SubcommandData... subcommands) Add up to 25Subcommandsto this command.deadline(long timestamp) Similar toRestAction.timeout(long, TimeUnit)but schedules a deadline at which the request has to be completed.setCheck(BooleanSupplier checks) Sets the last-second checks before finally executing the http request in the queue.setDefaultEnabled(boolean enabled) Whether this command is available to everyone by default.setDescription(String description) Configure the descriptionConfigure the command name.Timeout for this RestAction instance.Methods inherited from interface net.dv8tion.jda.api.interactions.commands.build.CommandData
getName, getType, isDefaultEnabledMethods 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, zipMethods inherited from interface net.dv8tion.jda.api.utils.data.SerializableData
toDataMethods inherited from interface net.dv8tion.jda.api.interactions.commands.build.SlashCommandData
getDescription, getOptions, getSubcommandGroups, getSubcommands
-
Method Details
-
setCheck
Description copied from interface:RestActionSets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalseor 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:
setCheckin interfaceRestAction<Command>- Parameters:
checks- The checks to run before executing the request, ornullto run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
-
addCheck
Description copied from interface:RestActionShortcut forsetCheck(() -> getCheck().getAsBoolean() && checks.getAsBoolean()).- Specified by:
addCheckin interfaceRestAction<Command>- Parameters:
checks- Other checks to run- Returns:
- The current RestAction for chaining convenience
- See Also:
-
timeout
Description copied from interface:RestActionTimeout 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:
timeoutin interfaceRestAction<Command>- Parameters:
timeout- The timeout to useunit-Unitfor the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
-
deadline
Description copied from interface:RestActionSimilar 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:
deadlinein interfaceRestAction<Command>- Parameters:
timestamp- Millisecond timestamp at which the request will timeout- Returns:
- The same RestAction with the applied deadline
- See Also:
-
setDefaultEnabled
Description copied from interface:CommandDataWhether 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).- Specified by:
setDefaultEnabledin interfaceCommandData- Specified by:
setDefaultEnabledin interfaceSlashCommandData- Parameters:
enabled- True, if this command is enabled by default for everyone. (Default: true)- Returns:
- The builder instance, for chaining
-
setName
Description copied from interface:CommandDataConfigure the command name.- Specified by:
setNamein interfaceCommandData- Specified by:
setNamein interfaceSlashCommandData- Parameters:
name- The name, 1-32 characters (lowercase and alphanumeric forCommand.Type.SLASH)- Returns:
- The builder instance, for chaining
-
setDescription
Description copied from interface:SlashCommandDataConfigure the description- Specified by:
setDescriptionin interfaceSlashCommandData- Parameters:
description- The description, 1-100 characters- Returns:
- The builder, for chaining
-
addOptions
Description copied from interface:SlashCommandDataAdds up to 25 options to this command.Required options must be added before non-required options!
- Specified by:
addOptionsin interfaceSlashCommandData- Parameters:
options- TheOptionsto add- Returns:
- The builder instance, for chaining
-
addOptions
@Nonnull @CheckReturnValue default CommandCreateAction addOptions(@Nonnull Collection<? extends OptionData> options) Description copied from interface:SlashCommandDataAdds up to 25 options to this command.Required options must be added before non-required options!
- Specified by:
addOptionsin interfaceSlashCommandData- Parameters:
options- TheOptionsto add- Returns:
- The builder instance, for chaining
-
addOption
@Nonnull @CheckReturnValue default CommandCreateAction addOption(@Nonnull OptionType type, @Nonnull String name, @Nonnull String description, boolean required, boolean autoComplete) Description copied from interface:SlashCommandDataAdds an option to this command.Required options must be added before non-required options!
- Specified by:
addOptionin interfaceSlashCommandData- Parameters:
type- TheOptionTypename- The lowercase option name, 1-32 charactersdescription- The option description, 1-100 charactersrequired- Whether this option is required (SeeOptionData.setRequired(boolean))autoComplete- Whether this option supports auto-complete viaCommandAutoCompleteInteractionEvent, only supported for option types whichsupport choices- Returns:
- The builder instance, for chaining
-
addOption
@Nonnull @CheckReturnValue default CommandCreateAction addOption(@Nonnull OptionType type, @Nonnull String name, @Nonnull String description, boolean required) Description copied from interface:SlashCommandDataAdds an option to this command.Required options must be added before non-required options!
- Specified by:
addOptionin interfaceSlashCommandData- Parameters:
type- TheOptionTypename- The lowercase option name, 1-32 charactersdescription- The option description, 1-100 charactersrequired- Whether this option is required (SeeOptionData.setRequired(boolean))- Returns:
- The builder instance, for chaining
-
addOption
@Nonnull @CheckReturnValue default CommandCreateAction addOption(@Nonnull OptionType type, @Nonnull String name, @Nonnull String description) Description copied from interface:SlashCommandDataAdds an option to this command.
The option is set to be non-required! You can useSlashCommandData.addOption(OptionType, String, String, boolean)to add a required option instead.Required options must be added before non-required options!
- Specified by:
addOptionin interfaceSlashCommandData- Parameters:
type- TheOptionTypename- The lowercase option name, 1-32 charactersdescription- The option description, 1-100 characters- Returns:
- The builder instance, for chaining
-
addSubcommands
@Nonnull @CheckReturnValue CommandCreateAction addSubcommands(@Nonnull SubcommandData... subcommands) Description copied from interface:SlashCommandDataAdd up to 25Subcommandsto this command.- Specified by:
addSubcommandsin interfaceSlashCommandData- Parameters:
subcommands- The subcommands to add- Returns:
- The builder instance, for chaining
-
addSubcommands
@Nonnull @CheckReturnValue default CommandCreateAction addSubcommands(@Nonnull Collection<? extends SubcommandData> subcommands) Description copied from interface:SlashCommandDataAdd up to 25Subcommandsto this command.- Specified by:
addSubcommandsin interfaceSlashCommandData- Parameters:
subcommands- The subcommands to add- Returns:
- The builder instance, for chaining
-
addSubcommandGroups
@Nonnull @CheckReturnValue CommandCreateAction addSubcommandGroups(@Nonnull SubcommandGroupData... groups) Description copied from interface:SlashCommandDataAdd up to 25Subcommand-Groupsto this command.- Specified by:
addSubcommandGroupsin interfaceSlashCommandData- Parameters:
groups- The subcommand groups to add- Returns:
- The builder instance, for chaining
-
addSubcommandGroups
@Nonnull @CheckReturnValue default CommandCreateAction addSubcommandGroups(@Nonnull Collection<? extends SubcommandGroupData> groups) Description copied from interface:SlashCommandDataAdd up to 25Subcommand-Groupsto this command.- Specified by:
addSubcommandGroupsin interfaceSlashCommandData- Parameters:
groups- The subcommand groups to add- Returns:
- The builder instance, for chaining
-