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 MessageChannel
getChannel()
The channel this interaction happened in.long
getCommandIdLong()
The command idjava.lang.String
getCommandString()
Gets the slash command String for this slash command.java.lang.String
getName()
The command name.java.util.List<OptionMapping>
getOptions()
The options provided by the user when this command was executed.java.lang.String
getSubcommandGroup()
The subcommand group name.java.lang.String
getSubcommandName()
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:Interaction
The channel this interaction happened in.
This is currently never null, but might be nullable in the future.- Specified by:
getChannel
in interfaceCommandInteraction
- Specified by:
getChannel
in interfaceInteraction
- Overrides:
getChannel
in 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:CommandInteraction
The 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:
getName
in interfaceCommandInteraction
- Returns:
- The command name
-
getSubcommandName
@Nullable public java.lang.String getSubcommandName()
Description copied from interface:CommandInteraction
The 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:
getSubcommandName
in interfaceCommandInteraction
- Returns:
- The subcommand name, or null if this is not a subcommand
-
getSubcommandGroup
@Nullable public java.lang.String getSubcommandGroup()
Description copied from interface:CommandInteraction
The 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:
getSubcommandGroup
in interfaceCommandInteraction
- Returns:
- The subcommand group name, or null if this is not a subcommand group
-
getCommandIdLong
public long getCommandIdLong()
Description copied from interface:CommandInteraction
The command id- Specified by:
getCommandIdLong
in interfaceCommandInteraction
- Returns:
- The command id
-
getOptions
@Nonnull public java.util.List<OptionMapping> getOptions()
Description copied from interface:CommandInteraction
The options provided by the user when this command was executed.
Each option has a name and value.- Specified by:
getOptions
in interfaceCommandInteraction
- Returns:
- The options passed for this command
-
getCommandString
@Nonnull public java.lang.String getCommandString()
Description copied from interface:CommandInteraction
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
- Specified by:
getCommandString
in interfaceCommandInteraction
- Returns:
- The command String for this slash command
-
-