Class CommandDataImpl
java.lang.Object
net.dv8tion.jda.internal.interactions.CommandDataImpl
- All Implemented Interfaces:
CommandData
,SlashCommandData
,SerializableData
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.interactions.commands.build.CommandData
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH, MAX_OPTIONS
-
Constructor Summary
ConstructorsConstructorDescriptionCommandDataImpl
(String name, String description) CommandDataImpl
(Command.Type type, String name) -
Method Summary
Modifier and TypeMethodDescriptionaddOptions
(OptionData... options) Adds up to 25 options to this command.addSubcommandGroups
(SubcommandGroupData... groups) Add up to 25Subcommand-Groups
to this command.addSubcommands
(SubcommandData... subcommands) Add up to 25Subcommands
to this command.void
checkDescription
(String description) void
The contexts in which this command can be used.Gets theDefaultMemberPermissions
of this command.The configured descriptionThe localizations of this command's description forvarious languages
.Gets the integration types on which this command can be installed on.getName()
The current command nameThe localizations of this command's name forvarious languages
.The options for this command.TheSubcommand Groups
in this command.TheSubcommands
in this command.getType()
TheCommand.Type
boolean
isNSFW()
Whether this command should only be usable in NSFW (age-restricted) channelsstatic CommandDataImpl
of
(Command.Type type, String name, String description) void
boolean
removeOptions
(Predicate<? super OptionData> condition) Removes all options that evaluate totrue
under the providedcondition
.boolean
removeSubcommandGroups
(Predicate<? super SubcommandGroupData> condition) Removes all subcommand groups that evaluate totrue
under the providedcondition
.boolean
removeSubcommands
(Predicate<? super SubcommandData> condition) Removes all subcommands that evaluate totrue
under the providedcondition
.setContexts
(Collection<InteractionContextType> contexts) Sets the contexts in which this command can be used (Default: Guild and Bot DMs).setDefaultPermissions
(DefaultMemberPermissions permissions) Sets thePermissions
that a user must have in a specific channel to be able to use this command.setDescription
(String description) Configure the descriptionsetDescriptionLocalization
(DiscordLocale locale, String description) Sets alanguage-specific
localizations of this command's description.Sets multiplelanguage-specific
localizations of this command's description.setIntegrationTypes
(Collection<IntegrationType> integrationTypes) Sets the integration types on which this command can be installed on (Default: Guilds).setLocalizationFunction
(LocalizationFunction localizationFunction) Sets theLocalizationFunction
for this command
This enables you to have the entirety of this command to be localized.Configure the command name.setNameLocalization
(DiscordLocale locale, String name) Sets alanguage-specific
localization of this command's name.Sets multiplelanguage-specific
localizations of this command's name.setNSFW
(boolean nsfw) Sets whether this command should only be usable in NSFW (age-restricted) channels.toData()
SerializedDataObject
for this object.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.interactions.commands.build.SlashCommandData
addOption, addOption, addOption, addOptions, addSubcommandGroups, addSubcommands, removeOptionByName, removeSubcommandByName, removeSubcommandGroupByName, setContexts, setIntegrationTypes
-
Constructor Details
-
CommandDataImpl
-
CommandDataImpl
-
-
Method Details
-
of
public static CommandDataImpl of(@Nonnull Command.Type type, @Nonnull String name, @Nullable String description) -
checkName
-
checkDescription
-
toData
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-
getType
Description copied from interface:CommandData
TheCommand.Type
- Specified by:
getType
in interfaceCommandData
- Returns:
- The
Command.Type
-
getDefaultPermissions
Description copied from interface:CommandData
Gets theDefaultMemberPermissions
of this command.
If no permissions have been set, this returnsDefaultMemberPermissions.ENABLED
.- Specified by:
getDefaultPermissions
in interfaceCommandData
- Returns:
- DefaultMemberPermissions of this command.
- See Also:
-
getContexts
Description copied from interface:CommandData
The contexts in which this command can be used.- Specified by:
getContexts
in interfaceCommandData
- Returns:
- The contexts in which this command can be used
-
getIntegrationTypes
Description copied from interface:CommandData
Gets the integration types on which this command can be installed on.- Specified by:
getIntegrationTypes
in interfaceCommandData
- Returns:
- The integration types on which this command can be installed on
-
isNSFW
public boolean isNSFW()Description copied from interface:CommandData
Whether this command should only be usable in NSFW (age-restricted) channels- Specified by:
isNSFW
in interfaceCommandData
- Returns:
- True, if this command is restricted to NSFW channels
- See Also:
-
getOptions
Description copied from interface:SlashCommandData
The options for this command.- Specified by:
getOptions
in interfaceSlashCommandData
- Returns:
- Immutable list of
OptionData
-
getSubcommands
Description copied from interface:SlashCommandData
TheSubcommands
in this command.- Specified by:
getSubcommands
in interfaceSlashCommandData
- Returns:
- Immutable list of
SubcommandData
-
getSubcommandGroups
Description copied from interface:SlashCommandData
TheSubcommand Groups
in this command.- Specified by:
getSubcommandGroups
in interfaceSlashCommandData
- Returns:
- Immutable list of
SubcommandGroupData
-
setDefaultPermissions
@Nonnull public CommandDataImpl setDefaultPermissions(@Nonnull DefaultMemberPermissions permissions) Description copied from interface:CommandData
Sets thePermissions
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 viaDefaultMemberPermissions.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.- Specified by:
setDefaultPermissions
in interfaceCommandData
- Specified by:
setDefaultPermissions
in interfaceSlashCommandData
- Parameters:
permissions
-DefaultMemberPermissions
representing the default permissions of this command.- Returns:
- The builder instance, for chaining
- See Also:
-
setContexts
Description copied from interface:CommandData
Sets the contexts in which this command can be used (Default: Guild and Bot DMs).
This only has an effect if this command is registered globally.- Specified by:
setContexts
in interfaceCommandData
- Specified by:
setContexts
in interfaceSlashCommandData
- Parameters:
contexts
- The contexts in which this command can be used- Returns:
- The builder instance, for chaining
-
setIntegrationTypes
@Nonnull public CommandDataImpl setIntegrationTypes(@Nonnull Collection<IntegrationType> integrationTypes) Description copied from interface:CommandData
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.- Specified by:
setIntegrationTypes
in interfaceCommandData
- Specified by:
setIntegrationTypes
in interfaceSlashCommandData
- Parameters:
integrationTypes
- The integration types on which this command can be installed on- Returns:
- The builder instance, for chaining
-
setNSFW
Description copied from interface:CommandData
Sets whether this command should only be usable in NSFW (age-restricted) channels.
Default: falseNote: Age-restricted commands will not show up in direct messages by default unless the user enables them in their settings.
- Specified by:
setNSFW
in interfaceCommandData
- Specified by:
setNSFW
in interfaceSlashCommandData
- Parameters:
nsfw
- True, to make this command nsfw- Returns:
- The builder instance, for chaining
- See Also:
-
addOptions
Description copied from interface:SlashCommandData
Adds up to 25 options to this command.Required options must be added before non-required options!
- Specified by:
addOptions
in interfaceSlashCommandData
- Parameters:
options
- TheOptions
to add- Returns:
- The builder instance, for chaining
-
addSubcommands
Description copied from interface:SlashCommandData
Add up to 25Subcommands
to this command.
When a subcommand or subcommand group is added, the base command itself cannot be used. Thus usingSlashCommandData.addOptions(OptionData...)
andSlashCommandData.addSubcommands(SubcommandData...)
/SlashCommandData.addSubcommandGroups(SubcommandGroupData...)
for the same command, is not supported.Valid command layouts are as follows:
Having an option and subcommand simultaneously is not allowed.command |-- subcommand |__ subcommand group |__ subcommand command |__ subcommand group |__ subcommand command |-- option |__ option
- Specified by:
addSubcommands
in interfaceSlashCommandData
- Parameters:
subcommands
- The subcommands to add- Returns:
- The builder instance, for chaining
-
addSubcommandGroups
Description copied from interface:SlashCommandData
Add up to 25Subcommand-Groups
to this command.
When a subcommand or subcommand group is added, the base command itself cannot be used. Thus usingSlashCommandData.addOptions(OptionData...)
andSlashCommandData.addSubcommands(SubcommandData...)
/SlashCommandData.addSubcommandGroups(SubcommandGroupData...)
for the same command, is not supported.Valid command layouts are as follows:
Having an option and subcommand simultaneously is not allowed.command |-- subcommand |__ subcommand group |__ subcommand command |__ subcommand group |__ subcommand command |-- option |__ option
- Specified by:
addSubcommandGroups
in interfaceSlashCommandData
- Parameters:
groups
- The subcommand groups to add- Returns:
- The builder instance, for chaining
-
setLocalizationFunction
@Nonnull public CommandDataImpl setLocalizationFunction(@Nonnull LocalizationFunction localizationFunction) Description copied from interface:CommandData
Sets theLocalizationFunction
for this command
This enables you to have the entirety of this command to be localized.- Specified by:
setLocalizationFunction
in interfaceCommandData
- Specified by:
setLocalizationFunction
in interfaceSlashCommandData
- Parameters:
localizationFunction
- The localization function- Returns:
- The builder instance, for chaining
-
setName
Description copied from interface:CommandData
Configure the command name.- Specified by:
setName
in interfaceCommandData
- Specified by:
setName
in interfaceSlashCommandData
- Parameters:
name
- The name, 1-32 characters (lowercase and alphanumeric forCommand.Type.SLASH
)- Returns:
- The builder instance, for chaining
-
setNameLocalization
@Nonnull public CommandDataImpl setNameLocalization(@Nonnull DiscordLocale locale, @Nonnull String name) Description copied from interface:CommandData
Sets alanguage-specific
localization of this command's name.- Specified by:
setNameLocalization
in interfaceCommandData
- Specified by:
setNameLocalization
in interfaceSlashCommandData
- Parameters:
locale
- The locale to associate the translated name withname
- The translated name to put- Returns:
- This builder instance, for chaining
-
setNameLocalizations
Description copied from interface:CommandData
Sets multiplelanguage-specific
localizations of this command's name.- Specified by:
setNameLocalizations
in interfaceCommandData
- Specified by:
setNameLocalizations
in interfaceSlashCommandData
- Parameters:
map
- The map from which to transfer the translated names- Returns:
- This builder instance, for chaining
-
setDescription
Description copied from interface:SlashCommandData
Configure the description- Specified by:
setDescription
in interfaceSlashCommandData
- Parameters:
description
- The description, 1-100 characters- Returns:
- The builder, for chaining
-
setDescriptionLocalization
@Nonnull public CommandDataImpl setDescriptionLocalization(@Nonnull DiscordLocale locale, @Nonnull String description) Description copied from interface:SlashCommandData
Sets alanguage-specific
localizations of this command's description.- Specified by:
setDescriptionLocalization
in interfaceSlashCommandData
- Parameters:
locale
- The locale to associate the translated description withdescription
- The translated description to put- Returns:
- This builder instance, for chaining
-
setDescriptionLocalizations
Description copied from interface:SlashCommandData
Sets multiplelanguage-specific
localizations of this command's description.- Specified by:
setDescriptionLocalizations
in interfaceSlashCommandData
- Parameters:
map
- The map from which to transfer the translated descriptions- Returns:
- This builder instance, for chaining
-
getName
Description copied from interface:CommandData
The current command name- Specified by:
getName
in interfaceCommandData
- Returns:
- The command name
-
getNameLocalizations
Description copied from interface:CommandData
The localizations of this command's name forvarious languages
.- Specified by:
getNameLocalizations
in interfaceCommandData
- Returns:
- The
LocalizationMap
containing the mapping fromDiscordLocale
to the localized name
-
getDescription
Description copied from interface:SlashCommandData
The configured description- Specified by:
getDescription
in interfaceSlashCommandData
- Returns:
- The description
-
getDescriptionLocalizations
Description copied from interface:SlashCommandData
The localizations of this command's description forvarious languages
.- Specified by:
getDescriptionLocalizations
in interfaceSlashCommandData
- Returns:
- The
LocalizationMap
containing the mapping fromDiscordLocale
to the localized description
-
removeOptions
Description copied from interface:SlashCommandData
Removes all options that evaluate totrue
under the providedcondition
.
This will not affect options within subcommands. UseSubcommandData.removeOptions(Predicate)
instead.Example: Remove all options
command.removeOptions(option -> true);
Example: Remove all options that are required
command.removeOptions(option -> option.isRequired());
- Specified by:
removeOptions
in interfaceSlashCommandData
- Parameters:
condition
- The removal condition (must not throw)- Returns:
- True, if any options were removed
-
removeSubcommands
Description copied from interface:SlashCommandData
Removes all subcommands that evaluate totrue
under the providedcondition
.
This will not apply to subcommands within subcommand groups. UseSubcommandGroupData.removeSubcommand(Predicate)
instead.Example: Remove all subcommands
command.removeSubcommands(subcommand -> true);
- Specified by:
removeSubcommands
in interfaceSlashCommandData
- Parameters:
condition
- The removal condition (must not throw)- Returns:
- True, if any subcommands were removed
-
removeSubcommandGroups
Description copied from interface:SlashCommandData
Removes all subcommand groups that evaluate totrue
under the providedcondition
.Example: Remove all subcommand groups
command.removeSubcommandGroups(group -> true);
- Specified by:
removeSubcommandGroups
in interfaceSlashCommandData
- Parameters:
condition
- The removal condition (must not throw)- Returns:
- True, if any subcommand groups were removed
-
removeAllOptions
public void removeAllOptions()
-