Class SlashCommandEvent
- java.lang.Object
-
- net.dv8tion.jda.api.events.Event
-
- net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
-
- net.dv8tion.jda.api.events.interaction.SlashCommandEvent
-
- All Implemented Interfaces:
ISnowflake,GenericEvent,CommandInteraction,Interaction
public class SlashCommandEvent extends GenericInteractionCreateEvent implements CommandInteraction
Indicates that a slash command was used in aMessageChannel.Requirements
To receive these events, you must unset the Interactions Endpoint URL in your application dashboard. You can simply remove the URL for this endpoint in your settings at the Discord Developers Portal.
-
-
Constructor Summary
Constructors Constructor Description SlashCommandEvent(JDA api, long responseNumber, net.dv8tion.jda.internal.interactions.CommandInteractionImpl interaction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageChannelgetChannel()The channel this interaction happened in.longgetCommandIdLong()The command idjava.lang.StringgetCommandString()Gets the slash command String for this slash command.java.lang.StringgetName()The command name.java.util.List<OptionMapping>getOptions()The options provided by the user when this command was executed.java.lang.StringgetSubcommandGroup()The subcommand group name.java.lang.StringgetSubcommandName()The subcommand name.-
Methods inherited from class net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
deferReply, getGuild, getHook, getIdLong, getInteraction, getMember, getToken, getTypeRaw, getUser, isAcknowledged
-
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getResponseNumber
-
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.CommandInteraction
getCommandId, getCommandPath, getOption, getOptionsByName, getOptionsByType
-
Methods inherited from interface net.dv8tion.jda.api.interactions.Interaction
deferReply, 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.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Constructor Detail
-
SlashCommandEvent
public SlashCommandEvent(@Nonnull JDA api, long responseNumber, @Nonnull net.dv8tion.jda.internal.interactions.CommandInteractionImpl interaction)
-
-
Method Detail
-
getChannel
@Nonnull public 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 interfaceCommandInteraction- Specified by:
getChannelin interfaceInteraction- Overrides:
getChannelin classGenericInteractionCreateEvent- Returns:
- The channel or null if this interaction is not from a channel context
-
getName
@Nonnull public java.lang.String getName()
Description copied from interface:CommandInteractionThe command name.
This can be useful for abstractions.Note that commands can have these following structures:
/name subcommandGroup subcommandName/name subcommandName/name
CommandInteraction.getCommandPath()to simplify your checks.- Specified by:
getNamein interfaceCommandInteraction- Returns:
- The command name
-
getSubcommandName
@Nullable public java.lang.String getSubcommandName()
Description copied from interface:CommandInteractionThe subcommand name.
This can be useful for abstractions.Note that commands can have these following structures:
/name subcommandGroup subcommandName/name subcommandName/name
CommandInteraction.getCommandPath()to simplify your checks.- Specified by:
getSubcommandNamein interfaceCommandInteraction- Returns:
- The subcommand name, or null if this is not a subcommand
-
getSubcommandGroup
@Nullable public java.lang.String getSubcommandGroup()
Description copied from interface:CommandInteractionThe subcommand group name.
This can be useful for abstractions.Note that commands can have these following structures:
/name subcommandGroup subcommandName/name subcommandName/name
CommandInteraction.getCommandPath()to simplify your checks.- Specified by:
getSubcommandGroupin interfaceCommandInteraction- Returns:
- The subcommand group name, or null if this is not a subcommand group
-
getCommandIdLong
public long getCommandIdLong()
Description copied from interface:CommandInteractionThe command id- Specified by:
getCommandIdLongin interfaceCommandInteraction- Returns:
- The command id
-
getOptions
@Nonnull public java.util.List<OptionMapping> getOptions()
Description copied from interface:CommandInteractionThe options provided by the user when this command was executed.
Each option has a name and value.- Specified by:
getOptionsin interfaceCommandInteraction- Returns:
- The options passed for this command
-
getCommandString
@Nonnull public java.lang.String getCommandString()
Description copied from interface:CommandInteractionGets 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- Specified by:
getCommandStringin interfaceCommandInteraction- Returns:
- The command String for this slash command
-
-