Interface SlashCommandData
- All Superinterfaces:
CommandData
,SerializableData
Extension of
CommandData
which allows setting slash-command specific settings such as options and subcommands.-
Method Summary
Modifier and TypeMethodDescriptiondefault SlashCommandData
addOption
(OptionType type, String name, String description) Adds an option to this command.default SlashCommandData
addOption
(OptionType type, String name, String description, boolean required) Adds an option to this command.default SlashCommandData
addOption
(OptionType type, String name, String description, boolean required, boolean autoComplete) Adds an option to this command.default SlashCommandData
addOptions
(Collection<? extends OptionData> options) Adds up to 25 options to this command.addOptions
(OptionData... options) Adds up to 25 options to this command.default SlashCommandData
addSubcommandGroups
(Collection<? extends SubcommandGroupData> groups) Add up to 25Subcommand-Groups
to this command.addSubcommandGroups
(SubcommandGroupData... groups) Add up to 25Subcommand-Groups
to this command.default SlashCommandData
addSubcommands
(Collection<? extends SubcommandData> subcommands) Add up to 25Subcommands
to this command.addSubcommands
(SubcommandData... subcommands) Add up to 25Subcommands
to this command.static SlashCommandData
fromCommand
(Command command) Converts the providedCommand
into a SlashCommandData instance.static SlashCommandData
fromData
(DataObject object) Parses the provided serialization back into a SlashCommandData instance.TheSubcommand Groups
in this command.TheSubcommands
in this command.Methods inherited from interface net.dv8tion.jda.api.interactions.commands.build.CommandData
getName, getType, setDefaultEnabled, setName
Methods inherited from interface net.dv8tion.jda.api.utils.data.SerializableData
toData
-
Method Details
-
getSubcommands
TheSubcommands
in this command.- Returns:
- Immutable list of
SubcommandData
-
getSubcommandGroups
TheSubcommand Groups
in this command.- Returns:
- Immutable list of
SubcommandGroupData
-
addOptions
Adds up to 25 options to this command.Required options must be added before non-required options!
- Parameters:
options
- TheOptions
to add- Returns:
- The CommandData instance, for chaining
- Throws:
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
Adds up to 25 options to this command.Required options must be added before non-required options!
- Parameters:
options
- TheOptions
to add- Returns:
- The CommandData instance, for chaining
- Throws:
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 default SlashCommandData addOption(@Nonnull OptionType type, @Nonnull String name, @Nonnull String description, boolean required, boolean autoComplete) Adds an option to this 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)
)autoComplete
- Whether this option supports auto-complete viaCommandAutoCompleteInteractionEvent
, only supported for option types whichsupport choices
- Returns:
- The CommandData instance, for chaining
- Throws:
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 the provided option type does not support auto-complete
- 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 default SlashCommandData addOption(@Nonnull OptionType type, @Nonnull String name, @Nonnull String description, boolean required) Adds an option to this 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 CommandData instance, for chaining
- Throws:
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 default SlashCommandData addOption(@Nonnull OptionType type, @Nonnull String name, @Nonnull String description) Adds an option to this command.
The option is set to be non-required! You can useaddOption(OptionType, String, String, boolean)
to add a required option instead.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 CommandData instance, for chaining
- Throws:
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
Add up to 25Subcommands
to this command.- Parameters:
subcommands
- The subcommands to add- Returns:
- The CommandData 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 default SlashCommandData addSubcommands(@Nonnull Collection<? extends SubcommandData> subcommands) Add up to 25Subcommands
to this command.- Parameters:
subcommands
- The subcommands to add- Returns:
- The CommandData 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
Add up to 25Subcommand-Groups
to this command.- Parameters:
groups
- The subcommand groups to add- Returns:
- The CommandData 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 default SlashCommandData addSubcommandGroups(@Nonnull Collection<? extends SubcommandGroupData> groups) Add up to 25Subcommand-Groups
to this command.- Parameters:
groups
- The subcommand groups to add- Returns:
- The CommandData 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.
-
fromCommand
Converts the providedCommand
into a SlashCommandData instance.- Parameters:
command
- The command to convert- Returns:
- An instance of SlashCommandData
- Throws:
IllegalArgumentException
- If null is provided or the command has illegal configuration- See Also:
-
fromData
Parses the provided serialization back into a SlashCommandData instance.
This is the reverse function forSerializableData.toData()
.- Parameters:
object
- The serializedDataObject
representing the command- Returns:
- The parsed SlashCommandData instance, which can be further configured through setters
- Throws:
ParsingException
- If the serialized object is missing required fieldsIllegalArgumentException
- If any of the values are failing the respective checks such as length- See Also:
-