Interface CommandInteractionPayload
-
- All Superinterfaces:
Interaction
,ISnowflake
- All Known Subinterfaces:
CommandAutoCompleteInteraction
,CommandInteraction
,ContextInteraction<T>
,MessageContextInteraction
,SlashCommandInteraction
,UserContextInteraction
- All Known Implementing Classes:
CommandAutoCompleteInteractionEvent
,GenericCommandInteractionEvent
,GenericContextInteractionEvent
,MessageContextInteractionEvent
,SlashCommandInteractionEvent
,UserContextInteractionEvent
public interface CommandInteractionPayload extends Interaction
Interactions which provide command data.
This is an abstraction forCommandAutoCompleteInteraction
andCommandInteraction
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default String
getCommandId()
The command id
This is the id generated when a command is created viaGuild.updateCommands()
or similar.long
getCommandIdLong()
The command id.default String
getCommandPath()
default String
getCommandString()
Gets the display string for this command.Command.Type
getCommandType()
TheType
of command this interaction is for.String
getName()
The command name.default OptionMapping
getOption(String name)
Finds the first option with the specified name.List<OptionMapping>
getOptions()
The options provided by the user when this command was executed.default List<OptionMapping>
getOptionsByName(String name)
Gets all options for the specified name.default List<OptionMapping>
getOptionsByType(OptionType type)
Gets all options for the specified type.String
getSubcommandGroup()
The subcommand group name.String
getSubcommandName()
The subcommand name.-
Methods inherited from interface net.dv8tion.jda.api.interactions.Interaction
getChannel, getChannelType, getGuild, getGuildChannel, getGuildLocale, getJDA, getMember, getMessageChannel, getNewsChannel, getPrivateChannel, getTextChannel, getThreadChannel, getToken, getType, getTypeRaw, getUser, getUserLocale, getVoiceChannel, isAcknowledged, isFromGuild
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Method Detail
-
getCommandType
@Nonnull Command.Type getCommandType()
TheType
of command this interaction is for.- Returns:
- The command type
-
getName
@Nonnull String getName()
The command name.
This can be useful for abstractions.Note that commands can have these following structures:
/name subcommandGroup subcommandName
/name subcommandName
/name
getCommandPath()
to simplify your checks.- Returns:
- The command name
-
getSubcommandName
@Nullable String getSubcommandName()
The subcommand name.
This can be useful for abstractions.Note that commands can have these following structures:
/name subcommandGroup subcommandName
/name subcommandName
/name
getCommandPath()
to simplify your checks.- Returns:
- The subcommand name, or null if this is not a subcommand
-
getSubcommandGroup
@Nullable String getSubcommandGroup()
The subcommand group name.
This can be useful for abstractions.Note that commands can have these following structures:
/name subcommandGroup subcommandName
/name subcommandName
/name
getCommandPath()
to simplify your checks.- Returns:
- The subcommand group name, or null if this is not a subcommand group
-
getCommandPath
@Nonnull default String getCommandPath()
Combination ofgetName()
,getSubcommandGroup()
, andgetSubcommandName()
.
This will format the command into a path such asmod/mute
wheremod
would be thegetName()
andmute
thegetSubcommandName()
.Examples:
/mod ban -> "mod/ban"
/admin config owner -> "admin/config/owner"
/ban -> "ban"
- Returns:
- The command path
-
getCommandString
@Nonnull default String getCommandString()
Gets the display string for this command.
This is similar to the string you see when clicking the interaction name in the client. For non-slash command types, this simply returnsgetName()
instead.Example return for an echo command:
/say echo phrase: Say this
- Returns:
- The display string for this command
-
getCommandIdLong
long getCommandIdLong()
The command id.
This is the id generated when a command is created viaGuild.updateCommands()
or similar.It is usually preferred to discriminate commands by the
command names
instead.- Returns:
- The command id
-
getCommandId
@Nonnull default String getCommandId()
The command id
This is the id generated when a command is created viaGuild.updateCommands()
or similar.It is usually preferred to discriminate commands by the
command names
instead.- Returns:
- The command id
-
getOptions
@Nonnull List<OptionMapping> getOptions()
The options provided by the user when this command was executed.
Each option has a name and value.For
CommandAutoCompleteInteraction
, this might be incomplete and unvalidated. Auto-complete interactions happen on incomplete command inputs and are not validated.- Returns:
- The options passed for this command
-
getOptionsByName
@Nonnull default List<OptionMapping> getOptionsByName(@Nonnull String name)
Gets all options for the specified name.For
CommandAutoCompleteInteraction
, this might be incomplete and unvalidated. Auto-complete interactions happen on incomplete command inputs and are not validated.- Parameters:
name
- The option name- Returns:
- The list of options
- Throws:
IllegalArgumentException
- If the provided name is null- See Also:
getOption(String)
-
getOptionsByType
@Nonnull default List<OptionMapping> getOptionsByType(@Nonnull OptionType type)
Gets all options for the specified type.For
CommandAutoCompleteInteraction
, this might be incomplete and unvalidated. Auto-complete interactions happen on incomplete command inputs and are not validated.- Parameters:
type
- The option type- Returns:
- The list of options
- Throws:
IllegalArgumentException
- If the provided type is null
-
getOption
@Nullable default OptionMapping getOption(@Nonnull String name)
Finds the first option with the specified name.For
CommandAutoCompleteInteraction
, this might be incomplete and unvalidated. Auto-complete interactions happen on incomplete command inputs and are not validated.- Parameters:
name
- The option name- Returns:
- The option with the provided name, or null if that option is not provided
- Throws:
IllegalArgumentException
- If the name is null
-
-