Class GenericComponentInteractionCreateEvent
- java.lang.Object
-
- net.dv8tion.jda.api.events.Event
-
- net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
-
- net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent
-
- All Implemented Interfaces:
ISnowflake,GenericEvent,IDeferrableCallback,IMessageEditCallback,IReplyCallback,ComponentInteraction,Interaction
- Direct Known Subclasses:
ButtonInteractionEvent,SelectMenuInteractionEvent
public class GenericComponentInteractionCreateEvent extends GenericInteractionCreateEvent implements ComponentInteraction
Indicates that aComponentInteractionwas created in a channel.
Every component interaction event is derived from this event.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 GenericComponentInteractionCreateEvent(JDA api, long responseNumber, ComponentInteraction interaction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageEditCallbackActiondeferEdit()No-op acknowledgement of this interaction.ReplyCallbackActiondeferReply()Acknowledge this interaction and defer the reply to a later time.MessageChannelgetChannel()The channel this interaction happened in.ActionComponentgetComponent()TheActionComponentinstance.StringgetComponentId()The custom component ID provided to the component when it was originally created.Component.TypegetComponentType()TheComponent.TypeInteractionHookgetHook()TheInteractionHookwhich can be used to send deferred replies or followup messages.ComponentInteractiongetInteraction()TheInteractioninstance.MessagegetMessage()TheMessageinstance.longgetMessageIdLong()The id of the message.-
Methods inherited from class net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
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.components.ComponentInteraction
getMessageId
-
Methods inherited from interface net.dv8tion.jda.api.interactions.callbacks.IMessageEditCallback
editComponents, editComponents, editMessage, editMessage, editMessageEmbeds, editMessageEmbeds, editMessageFormat
-
Methods inherited from interface net.dv8tion.jda.api.interactions.Interaction
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
-
GenericComponentInteractionCreateEvent
public GenericComponentInteractionCreateEvent(@Nonnull JDA api, long responseNumber, @Nonnull ComponentInteraction interaction)
-
-
Method Detail
-
getInteraction
@Nonnull public ComponentInteraction getInteraction()
Description copied from class:GenericInteractionCreateEventTheInteractioninstance.
Note that this event is a delegate which implements the same interface.- Overrides:
getInteractionin classGenericInteractionCreateEvent- Returns:
- The
Interaction
-
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 interfaceComponentInteraction- Specified by:
getChannelin interfaceInteraction- Overrides:
getChannelin classGenericInteractionCreateEvent- Returns:
- The channel or null if this interaction is not from a channel context
-
getComponentId
@Nonnull public String getComponentId()
Description copied from interface:ComponentInteractionThe custom component ID provided to the component when it was originally created.
This value should be used to determine what action to take in regard to this interaction.
This id does not have to be numerical.- Specified by:
getComponentIdin interfaceComponentInteraction- Returns:
- The component ID
- See Also:
ActionComponent.getId()
-
getComponent
@Nonnull public ActionComponent getComponent()
Description copied from interface:ComponentInteractionTheActionComponentinstance.- Specified by:
getComponentin interfaceComponentInteraction- Returns:
- The
ActionComponent
-
getMessage
@Nonnull public Message getMessage()
Description copied from interface:ComponentInteractionTheMessageinstance.- Specified by:
getMessagein interfaceComponentInteraction- Returns:
- The
Message
-
getMessageIdLong
public long getMessageIdLong()
Description copied from interface:ComponentInteractionThe id of the message.- Specified by:
getMessageIdLongin interfaceComponentInteraction- Returns:
- The message id
-
getComponentType
@Nonnull public Component.Type getComponentType()
Description copied from interface:ComponentInteractionTheComponent.Type- Specified by:
getComponentTypein interfaceComponentInteraction- Returns:
- The
Component.Type
-
deferEdit
@Nonnull public MessageEditCallbackAction deferEdit()
Description copied from interface:IMessageEditCallbackNo-op acknowledgement of this interaction.
This tells discord you intend to update the message that the triggering component is a part of using theInteractionHookinstead of sending a reply message. You are not required to actually update the message, this will simply acknowledge that you accepted the interaction.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receiveErrorResponse.UNKNOWN_INTERACTION.Use
IMessageEditCallback.editMessage(String)to edit it directly.- Specified by:
deferEditin interfaceIMessageEditCallback- Returns:
MessageEditCallbackActionthat can be used to update the message- See Also:
IMessageEditCallback.editMessage(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
-
-