Class ComponentInteractionEvent
- java.lang.Object
-
- discord4j.core.event.domain.Event
-
- discord4j.core.event.domain.interaction.InteractionCreateEvent
-
- discord4j.core.event.domain.interaction.DeferrableInteractionEvent
-
- discord4j.core.event.domain.interaction.ComponentInteractionEvent
-
- Direct Known Subclasses:
ButtonInteractionEvent
,SelectMenuInteractionEvent
public class ComponentInteractionEvent extends DeferrableInteractionEvent
Dispatched when a user interacts with aMessageComponent
the bot has sent.You are required to respond to this interaction within a three-second window by using one of the following:
DeferrableInteractionEvent.reply()
to directly include a messageDeferrableInteractionEvent.deferReply()
to acknowledge without a message, typically to perform a background task and give the user a loading state until it is editededit()
to modify the message the component is ondeferEdit()
to acknowledge without a message, will not display a loading state and allows later modifications to the message the component is on
InteractionCreateEvent
for more details about valid operations.This is not directly dispatched by Discord, but is a utility specialization of
InteractionCreateEvent
.
-
-
Constructor Summary
Constructors Constructor Description ComponentInteractionEvent(GatewayDiscordClient gateway, ShardInfo shardInfo, Interaction interaction)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Mono<Void>
acknowledge()
Deprecated.for components, migrate todeferEdit()
Mono<Void>
acknowledgeEphemeral()
Deprecated.for components, migrate todeferEdit().withEphemeral(true)
discord4j.core.spec.InteractionCallbackSpecDeferEditMono
deferEdit()
Acknowledge the interaction by indicating a message will be edited later.Mono<Void>
deferEdit(discord4j.core.spec.InteractionCallbackSpec spec)
Acknowledge the interaction by indicating a message will be edited later.discord4j.core.spec.InteractionApplicationCommandCallbackEditMono
edit()
Requests to respond to the interaction by immediately editing the message the button is on.Mono<Void>
edit(discord4j.core.spec.InteractionApplicationCommandCallbackSpec spec)
Requests to respond to the interaction by immediately editing the message the button is on.discord4j.core.spec.InteractionApplicationCommandCallbackEditMono
edit(String content)
Requests to respond to the interaction by immediately editing the message the button is on with the given message content.Mono<Void>
edit(Consumer<? super LegacyInteractionApplicationCommandCallbackSpec> spec)
Deprecated.useedit()
,edit(InteractionApplicationCommandCallbackSpec)
which offer an immutable approach to build specsString
getCustomId()
Gets the developer-defined custom id associated with the component.Optional<Message>
getMessage()
Gets the message the component is on.Snowflake
getMessageId()
Gets the ID of the message the component is on.-
Methods inherited from class discord4j.core.event.domain.interaction.DeferrableInteractionEvent
createFollowup, createFollowup, createFollowup, deferReply, deferReply, deleteFollowup, deleteReply, editFollowup, editFollowup, editReply, editReply, editReply, getInteractionResponse, getReply, reply, reply, reply, reply
-
Methods inherited from class discord4j.core.event.domain.interaction.InteractionCreateEvent
createInteractionResponse, getInteraction
-
Methods inherited from class discord4j.core.event.domain.Event
getClient, getShardInfo
-
-
-
-
Constructor Detail
-
ComponentInteractionEvent
public ComponentInteractionEvent(GatewayDiscordClient gateway, ShardInfo shardInfo, Interaction interaction)
-
-
Method Detail
-
getCustomId
public String getCustomId()
Gets the developer-defined custom id associated with the component.- Returns:
- The component's custom id.
- See Also:
Button.getCustomId()
-
getMessage
public Optional<Message> getMessage()
Gets the message the component is on.For ephemeral messages, only the ID is present. Use
getMessageId()
- Returns:
- The message the component is on.
-
getMessageId
public Snowflake getMessageId()
Gets the ID of the message the component is on.- Returns:
- The ID of the message the component is on.
-
deferEdit
public discord4j.core.spec.InteractionCallbackSpecDeferEditMono deferEdit()
Acknowledge the interaction by indicating a message will be edited later. For components, the user does not see a loading state. For an "only you can see this" response, addwithEphemeral(true)
, or to directly edit it,edit().withEphemeral(true)
.After calling
deferEdit
, you are not allowed to call other acknowledge, reply or edit method and have to either work with the initial reply usingDeferrableInteractionEvent.getReply()
,DeferrableInteractionEvent.editReply()
,DeferrableInteractionEvent.deleteReply()
, or using followup messages withDeferrableInteractionEvent.createFollowup()
,DeferrableInteractionEvent.editFollowup(Snowflake)
orDeferrableInteractionEvent.deleteFollowup(Snowflake)
.- Returns:
- a
InteractionCallbackSpecDeferEditMono
where, upon successful completion, emits nothing; acknowledging the interaction and indicating a response will be edited later. If an error is received, it is emitted through it.
-
deferEdit
public Mono<Void> deferEdit(discord4j.core.spec.InteractionCallbackSpec spec)
Acknowledge the interaction by indicating a message will be edited later. For components, the user does not see a loading state.After calling
deferEdit
, you are not allowed to call other acknowledge, reply or edit method and have to either work with the initial reply usingDeferrableInteractionEvent.getReply()
,DeferrableInteractionEvent.editReply()
,DeferrableInteractionEvent.deleteReply()
, or using followup messages withDeferrableInteractionEvent.createFollowup()
,DeferrableInteractionEvent.editFollowup(Snowflake)
orDeferrableInteractionEvent.deleteFollowup(Snowflake)
.- Parameters:
spec
- an immutable object that specifies how to build the reply message to the interaction- Returns:
- A
Mono
where, upon successful completion, emits nothing; acknowledging the interaction and indicating a response will be edited later. The user sees a loading state. If an error is received, it is emitted through theMono
.
-
edit
@Deprecated public Mono<Void> edit(Consumer<? super LegacyInteractionApplicationCommandCallbackSpec> spec)
Deprecated.useedit()
,edit(InteractionApplicationCommandCallbackSpec)
which offer an immutable approach to build specsRequests to respond to the interaction by immediately editing the message the button is on.
-
edit
public discord4j.core.spec.InteractionApplicationCommandCallbackEditMono edit()
Requests to respond to the interaction by immediately editing the message the button is on. Properties specifying how to edit the message can be set via thewithXxx
methods of the returnedInteractionApplicationCommandCallbackEditMono
.After calling
edit
, you are not allowed to call other acknowledging, reply or edit method and have to either work with the initial reply usingDeferrableInteractionEvent.getReply()
,DeferrableInteractionEvent.editReply()
,DeferrableInteractionEvent.deleteReply()
, or using followup messages withDeferrableInteractionEvent.createFollowup()
,DeferrableInteractionEvent.editFollowup(Snowflake)
orDeferrableInteractionEvent.deleteFollowup(Snowflake)
.- Returns:
- A
InteractionApplicationCommandCallbackEditMono
where, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theInteractionApplicationCommandCallbackMono
.
-
edit
public discord4j.core.spec.InteractionApplicationCommandCallbackEditMono edit(String content)
Requests to respond to the interaction by immediately editing the message the button is on with the given message content. Properties specifying how to edit the message can be set via thewithXxx
methods of the returnedInteractionApplicationCommandCallbackEditMono
.After calling
edit
, you are not allowed to call other acknowledging, reply or edit method and have to either work with the initial reply usingDeferrableInteractionEvent.getReply()
,DeferrableInteractionEvent.editReply()
,DeferrableInteractionEvent.deleteReply()
, or using followup messages withDeferrableInteractionEvent.createFollowup()
,DeferrableInteractionEvent.editFollowup(Snowflake)
orDeferrableInteractionEvent.deleteFollowup(Snowflake)
.- Returns:
- A
InteractionApplicationCommandCallbackEditMono
where, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theInteractionApplicationCommandCallbackMono
.
-
edit
public Mono<Void> edit(discord4j.core.spec.InteractionApplicationCommandCallbackSpec spec)
Requests to respond to the interaction by immediately editing the message the button is on.After calling
edit
, you are not allowed to call other acknowledging, reply or edit method and have to either work with the initial reply usingDeferrableInteractionEvent.getReply()
,DeferrableInteractionEvent.editReply()
,DeferrableInteractionEvent.deleteReply()
, or using followup messages withDeferrableInteractionEvent.createFollowup()
,DeferrableInteractionEvent.editFollowup(Snowflake)
orDeferrableInteractionEvent.deleteFollowup(Snowflake)
.- Parameters:
spec
- an immutable object that specifies how to edit the message the button is on.- Returns:
- A
Mono
where, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theMono
.
-
acknowledge
public Mono<Void> acknowledge()
Deprecated.for components, migrate todeferEdit()
Acknowledge the interaction by indicating a message will be edited later. For components, the user does not see a loading state.- Overrides:
acknowledge
in classDeferrableInteractionEvent
- Returns:
- A
Mono
where, upon successful completion, emits nothing; acknowledging the interaction and indicating a response will be edited later. The user sees a loading state. If an error is received, it is emitted through theMono
.
-
acknowledgeEphemeral
public Mono<Void> acknowledgeEphemeral()
Deprecated.for components, migrate todeferEdit().withEphemeral(true)
Acknowledges the interaction indicating a response will be edited later. For components, the user does not see a loading state.- Overrides:
acknowledgeEphemeral
in classDeferrableInteractionEvent
- Returns:
- A
Mono
where, upon successful completion, emits nothing, acknowledging the interaction and indicating a response will be edited later. If an error is received, it is emitted through theMono
.
-
-