Class GenericCommandInteractionEvent
- java.lang.Object
-
- net.dv8tion.jda.api.events.Event
-
- net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
-
- net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent
-
- All Implemented Interfaces:
ISnowflake,GenericEvent,IDeferrableCallback,IReplyCallback,CommandInteraction,CommandInteractionPayload,Interaction
- Direct Known Subclasses:
GenericContextInteractionEvent,SlashCommandInteractionEvent
public class GenericCommandInteractionEvent extends GenericInteractionCreateEvent implements CommandInteraction
Indicates that aCommandInteractionwas used.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 GenericCommandInteractionEvent(JDA api, long responseNumber, CommandInteraction interaction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReplyCallbackActiondeferReply()Acknowledge this interaction and defer the reply to a later time.longgetCommandIdLong()The command id.Command.TypegetCommandType()TheTypeof command this interaction is for.InteractionHookgetHook()TheInteractionHookwhich can be used to send deferred replies or followup messages.CommandInteractiongetInteraction()TheInteractioninstance.StringgetName()The command name.List<OptionMapping>getOptions()The options provided by the user when this command was executed.StringgetSubcommandGroup()The subcommand group name.StringgetSubcommandName()The subcommand name.-
Methods inherited from class net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
getChannel, getGuild, getGuildLocale, getIdLong, getMember, getToken, getTypeRaw, getUser, getUserLocale, 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.CommandInteractionPayload
getCommandId, getCommandPath, getCommandString, getOption, getOption, getOption, getOption, getOptionsByName, getOptionsByType
-
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.interactions.callbacks.IReplyCallback
deferReply, reply, reply, replyEmbeds, replyEmbeds, replyFile, replyFile, replyFile, replyFile, replyFormat
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Constructor Detail
-
GenericCommandInteractionEvent
public GenericCommandInteractionEvent(@Nonnull JDA api, long responseNumber, @Nonnull CommandInteraction interaction)
-
-
Method Detail
-
getInteraction
@Nonnull public CommandInteraction getInteraction()
Description copied from class:GenericInteractionCreateEventTheInteractioninstance.
Note that this event is a delegate which implements the same interface.- Overrides:
getInteractionin classGenericInteractionCreateEvent- Returns:
- The
Interaction
-
getCommandType
@Nonnull public Command.Type getCommandType()
Description copied from interface:CommandInteractionPayloadTheTypeof command this interaction is for.- Specified by:
getCommandTypein interfaceCommandInteractionPayload- Returns:
- The command type
-
getName
@Nonnull public String getName()
Description copied from interface:CommandInteractionPayloadThe command name.
This can be useful for abstractions.Note that commands can have these following structures:
/name subcommandGroup subcommandName/name subcommandName/name
CommandInteractionPayload.getCommandPath()to simplify your checks.- Specified by:
getNamein interfaceCommandInteractionPayload- Returns:
- The command name
-
getSubcommandName
@Nullable public String getSubcommandName()
Description copied from interface:CommandInteractionPayloadThe subcommand name.
This can be useful for abstractions.Note that commands can have these following structures:
/name subcommandGroup subcommandName/name subcommandName/name
CommandInteractionPayload.getCommandPath()to simplify your checks.- Specified by:
getSubcommandNamein interfaceCommandInteractionPayload- Returns:
- The subcommand name, or null if this is not a subcommand
-
getSubcommandGroup
@Nullable public String getSubcommandGroup()
Description copied from interface:CommandInteractionPayloadThe subcommand group name.
This can be useful for abstractions.Note that commands can have these following structures:
/name subcommandGroup subcommandName/name subcommandName/name
CommandInteractionPayload.getCommandPath()to simplify your checks.- Specified by:
getSubcommandGroupin interfaceCommandInteractionPayload- Returns:
- The subcommand group name, or null if this is not a subcommand group
-
getCommandIdLong
public long getCommandIdLong()
Description copied from interface:CommandInteractionPayloadThe 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 namesinstead.- Specified by:
getCommandIdLongin interfaceCommandInteractionPayload- Returns:
- The command id
-
getOptions
@Nonnull public List<OptionMapping> getOptions()
Description copied from interface:CommandInteractionPayloadThe 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.- Specified by:
getOptionsin interfaceCommandInteractionPayload- Returns:
- The options passed for this command
- See Also:
CommandInteractionPayload.getOption(String)
-
getHook
@Nonnull public InteractionHook getHook()
Description copied from interface:IDeferrableCallbackTheInteractionHookwhich can be used to send deferred replies or followup messages.- Specified by:
getHookin interfaceIDeferrableCallback- Returns:
- The interaction hook
-
deferReply
@Nonnull public ReplyCallbackAction deferReply()
Description copied from interface:IReplyCallbackAcknowledge this interaction and defer the reply to a later time.
This will send a<Bot> is thinking...message in chat that will be updated later through eitherInteractionHook.editOriginal(String)orWebhookClient.sendMessage(String).You can use
deferReply(true)to send a deferred ephemeral reply. If your initial deferred message is not ephemeral it cannot be made ephemeral later. Your first message to theInteractionHookwill inherit whether the message is ephemeral or not from this deferred reply.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION.Use
IReplyCallback.reply(String)to reply directly.- Specified by:
deferReplyin interfaceIReplyCallback- Returns:
ReplyCallbackAction
-
-