Class ComponentEvent
- All Implemented Interfaces:
net.dv8tion.jda.api.entities.ISnowflake, net.dv8tion.jda.api.interactions.Interaction
Event. It provides additional features for replying to a GenericComponentInteractionCreateEvent.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidNo-op acknowledgement of this interaction.voiddeferReply(boolean ephemeral) Acknowledge this interaction and defer the reply to a later time.<T extends net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent>
TReturns the underlyingGenericComponentInteractionCreateEventand casts it to the given type.voidRemoves all components from the original message.net.dv8tion.jda.api.entities.Messagereply()No-op acknowledgement of this event with the V2 Components of the original reply.net.dv8tion.jda.api.entities.MessageAcknowledgement of this event with the V2 Components of the original reply.with()Entry point for configuring a reply.Methods inherited from class ModalReplyableEvent
replyModal, replyModal, replyModal, replyModalMethods inherited from class ReplyableEvent
deferReply, embed, findEmbed, getButton, getButton, getSelectMenu, getSelectMenu, reply, reply, reply, reply, replyMethods inherited from class Event
closeRuntime, getChannel, getChannelIdLong, getContext, getEntitlements, getGuild, getIdLong, getIntegrationOwners, getJDA, getMember, getToken, getTypeRaw, getUser, getUserLocale, interactionInstance, introspection, isAcknowledged, jdaEvent, kv, messageResolver, resolve, runtimeIdMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.dv8tion.jda.api.interactions.Interaction
getChannelId, getChannelType, getGuildChannel, getGuildLocale, getMessageChannel, getType, isFromAttachedGuild, isFromGuildMethods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
-
Constructor Details
-
ComponentEvent
public ComponentEvent()
-
-
Method Details
-
jdaEvent
public <T extends net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent> T jdaEvent(Class<T> type) Returns the underlyingGenericComponentInteractionCreateEventand casts it to the given type.- Type Parameters:
T- a subtype ofGenericComponentInteractionCreateEvent- Parameters:
type- a subtype ofGenericComponentInteractionCreateEvent, namelyButtonInteractionEvent,EntitySelectInteractionEventorStringSelectInteractionEvent- Returns:
Tthe event
-
deferReply
public void deferReply(boolean ephemeral) Description copied from class:ReplyableEventAcknowledge 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. This will use the passed boolean to set the ephemeral flag. If your initial deferred message is ephemeral it cannot be made non-ephemeral later. UseReplyableEvent.deferReply()to use theInteractionDefinition.ReplyConfigfor the ephemeral flag.You only have 3 seconds to acknowledge an interaction!
When the acknowledgement is sent after the interaction expired, you will receive
ErrorResponse.UNKNOWN_INTERACTION.Use
ReplyableEvent.reply(String, Entry...)to reply directly.- Specified by:
deferReplyin classReplyableEvent<net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent>- Parameters:
ephemeral- yes
-
deferEdit
public void deferEdit()No-op acknowledgement of this interaction.
This tells discord you intend to update the message that the triggering component is a part of instead 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 receive
ErrorResponse.UNKNOWN_INTERACTION.Use
ReplyableEvent.reply(String, Entry...)to edit it directly. -
removeComponents
public void removeComponents()Removes all components from the original message.
The original message is the message, from which this event (interaction) originates. For example if this event is a ButtonEvent, the original message will be the message to which the pressed button is attached to.
-
with
Description copied from class:ReplyableEventEntry point for configuring a reply.
Returns a new
ConfigurableReplythat can be used to append components or override reply settings.- Overrides:
within classReplyableEvent<net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent>- Returns:
- a new
ConfigurableReply - See Also:
-
reply
public net.dv8tion.jda.api.entities.Message reply()No-op acknowledgement of this event with the V2 Components of the original reply.
Calling this method will enforce
EditableConfigurableReply.keepComponents(boolean)totrueto retrieve the original components.- Throws:
UnsupportedOperationException- if the original message didn't use V2 Components
-
reply
public net.dv8tion.jda.api.entities.Message reply(net.dv8tion.jda.api.components.replacer.ComponentReplacer replacer, Entry... placeholder) Acknowledgement of this event with the V2 Components of the original reply. Will also apply the passed
ComponentReplacerbefore sending the reply.Calling this method will enforce
EditableConfigurableReply.keepComponents(boolean)totrueto retrieve the original components.- Parameters:
replacer- theComponentReplacerto apply to the original componentsplaceholder- the placeholders to use. SeePlaceholderResolver- Throws:
UnsupportedOperationException- if the original message didn't use V2 Components- Implementation Note:
- The
ComponentReplaceronly gets applied after the original components were retrieved and, ifEditableConfigurableReply.keepSelections(boolean)is set totrue, after the selections are retrieved.
-