Class GenericInteractionCreateEvent
- java.lang.Object
-
- net.dv8tion.jda.api.events.Event
-
- net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
-
- All Implemented Interfaces:
ISnowflake
,GenericEvent
,Interaction
- Direct Known Subclasses:
GenericComponentInteractionCreateEvent
,SlashCommandEvent
@Incubating public class GenericInteractionCreateEvent extends Event implements Interaction
Indicates that anInteraction
was created in a channel.
Every 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 GenericInteractionCreateEvent(JDA api, long responseNumber, Interaction interaction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReplyAction
deferReply()
Acknowledge this interaction and defer the reply to a later time.AbstractChannel
getChannel()
The channel this interaction happened in.Guild
getGuild()
TheGuild
this interaction happened in.InteractionHook
getHook()
TheInteractionHook
which can be used to send deferred replies or followup messages.long
getIdLong()
The Snowflake id of this entity.Interaction
getInteraction()
TheInteraction
instance.Member
getMember()
TheMember
who caused this interaction.java.lang.String
getToken()
The interaction token used for responding to an interaction.int
getTypeRaw()
The raw interaction type.User
getUser()
TheUser
who caused this interaction.boolean
isAcknowledged()
Whether this interaction has already been acknowledged.-
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.Interaction
deferReply, getChannelType, getGuildChannel, getJDA, getMessageChannel, getPrivateChannel, getTextChannel, getType, getVoiceChannel, isFromGuild, reply, reply, replyEmbeds, replyEmbeds, replyFormat
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
-
-
-
-
Constructor Detail
-
GenericInteractionCreateEvent
public GenericInteractionCreateEvent(@Nonnull JDA api, long responseNumber, @Nonnull Interaction interaction)
-
-
Method Detail
-
getInteraction
@Nonnull public Interaction getInteraction()
TheInteraction
instance.
Note that this event is a delegate which implements the same interface.- Returns:
- The
Interaction
-
getToken
@Nonnull public java.lang.String getToken()
Description copied from interface:Interaction
The interaction token used for responding to an interaction.- Specified by:
getToken
in interfaceInteraction
- Returns:
- The interaction token
-
getTypeRaw
public int getTypeRaw()
Description copied from interface:Interaction
The raw interaction type.
It is recommended to useInteraction.getType()
instead.- Specified by:
getTypeRaw
in interfaceInteraction
- Returns:
- The raw interaction type
-
getGuild
@Nullable public Guild getGuild()
Description copied from interface:Interaction
TheGuild
this interaction happened in.
This is null in direct messages.- Specified by:
getGuild
in interfaceInteraction
- Returns:
- The
Guild
or null
-
getChannel
@Nullable public AbstractChannel 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 interfaceInteraction
- Returns:
- The channel or null if this interaction is not from a channel context
-
getHook
@Nonnull public InteractionHook getHook()
Description copied from interface:Interaction
TheInteractionHook
which can be used to send deferred replies or followup messages.- Specified by:
getHook
in interfaceInteraction
- Returns:
- The interaction hook
-
getMember
@Nullable public Member getMember()
Description copied from interface:Interaction
TheMember
who caused this interaction.
This is null if the interaction is not from a guild.- Specified by:
getMember
in interfaceInteraction
- Returns:
- The
Member
-
getUser
@Nonnull public User getUser()
Description copied from interface:Interaction
TheUser
who caused this interaction.- Specified by:
getUser
in interfaceInteraction
- Returns:
- The
User
-
getIdLong
public long getIdLong()
Description copied from interface:ISnowflake
The Snowflake id of this entity. This is unique to every entity and will never change.- Specified by:
getIdLong
in interfaceISnowflake
- Returns:
- Long containing the Id.
-
isAcknowledged
public boolean isAcknowledged()
Description copied from interface:Interaction
Whether this interaction has already been acknowledged.
BothInteraction.deferReply()
andInteraction.reply(String)
acknowledge an interaction. Each interaction can only be acknowledged once.- Specified by:
isAcknowledged
in interfaceInteraction
- Returns:
- True, if this interaction has already been acknowledged
-
deferReply
@Nonnull public ReplyAction deferReply()
Description copied from interface:Interaction
Acknowledge 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 theInteractionHook
will 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
Interaction.reply(String)
to reply directly.- Specified by:
deferReply
in interfaceInteraction
- Returns:
ReplyAction
-
-