Interface CommandInteraction
- 
- All Superinterfaces:
- Interaction,- ISnowflake
 - All Known Implementing Classes:
- SlashCommandEvent
 
 public interface CommandInteraction extends Interaction Interaction of a Slash-Command.- See Also:
- SlashCommandEvent
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description MessageChannelgetChannel()The channel this interaction happened in.default java.lang.StringgetCommandId()The command idlonggetCommandIdLong()The command iddefault java.lang.StringgetCommandPath()default java.lang.StringgetCommandString()Gets the slash command String for this slash command.java.lang.StringgetName()The command name.default OptionMappinggetOption(java.lang.String name)Finds the first option with the specified name.java.util.List<OptionMapping>getOptions()The options provided by the user when this command was executed.default java.util.List<OptionMapping>getOptionsByName(java.lang.String name)Gets all options for the specified name.default java.util.List<OptionMapping>getOptionsByType(OptionType type)Gets all options for the specified type.java.lang.StringgetSubcommandGroup()The subcommand group name.java.lang.StringgetSubcommandName()The subcommand name.- 
Methods inherited from interface net.dv8tion.jda.api.interactions.InteractiondeferReply, deferReply, getChannelType, getGuild, getGuildChannel, getHook, getJDA, getMember, getMessageChannel, getPrivateChannel, getTextChannel, getToken, getType, getTypeRaw, getUser, getVoiceChannel, isAcknowledged, isFromGuild, reply, reply, replyEmbeds, replyEmbeds, replyFormat
 - 
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflakegetId, getIdLong, getTimeCreated
 
- 
 
- 
- 
- 
Method Detail- 
getName@Nonnull java.lang.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 java.lang.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 java.lang.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 java.lang.String getCommandPath() Combination ofgetName(),getSubcommandGroup(), andgetSubcommandName().
 This will format the command into a path such asmod/mutewheremodwould be thegetName()andmutethegetSubcommandName().Examples: - /mod ban -> "mod/ban"
- /admin config owner -> "admin/config/owner"
- /ban -> "ban"
 - Returns:
- The command path
 
 - 
getChannel@Nonnull MessageChannel getChannel() Description copied from interface:InteractionThe channel this interaction happened in.
 This is currently never null, but might be nullable in the future.- Specified by:
- getChannelin interface- Interaction
- Returns:
- The channel or null if this interaction is not from a channel context
 
 - 
getCommandIdLonglong getCommandIdLong() The command id- Returns:
- The command id
 
 - 
getCommandId@Nonnull default java.lang.String getCommandId() The command id- Returns:
- The command id
 
 - 
getOptions@Nonnull java.util.List<OptionMapping> getOptions() The options provided by the user when this command was executed.
 Each option has a name and value.- Returns:
- The options passed for this command
 
 - 
getOptionsByName@Nonnull default java.util.List<OptionMapping> getOptionsByName(@Nonnull java.lang.String name) Gets all options for the specified name.- Parameters:
- name- The option name
- Returns:
- The list of options
- Throws:
- java.lang.IllegalArgumentException- If the provided name is null
- See Also:
- getOption(String)
 
 - 
getOptionsByType@Nonnull default java.util.List<OptionMapping> getOptionsByType(@Nonnull OptionType type) Gets all options for the specified type.- Parameters:
- type- The option type
- Returns:
- The list of options
- Throws:
- java.lang.IllegalArgumentException- If the provided type is null
 
 - 
getOption@Nullable default OptionMapping getOption(@Nonnull java.lang.String name) Finds the first option with the specified name.- Parameters:
- name- The option name
- Returns:
- The option with the provided name, or null if that option is not provided
- Throws:
- java.lang.IllegalArgumentException- If the name is null
 
 - 
getCommandString@Nonnull default java.lang.String getCommandString() Gets the slash command String for this slash command.
 This is similar to the String you see when clicking the interaction name in the client.Example return for an echo command: /say echo phrase: Say this- Returns:
- The command String for this slash command
 
 
- 
 
-