Class DeferrableInteractionEvent
- java.lang.Object
-
- discord4j.core.event.domain.Event
-
- discord4j.core.event.domain.interaction.InteractionCreateEvent
-
- discord4j.core.event.domain.interaction.DeferrableInteractionEvent
-
- Direct Known Subclasses:
ApplicationCommandInteractionEvent,ComponentInteractionEvent
@Experimental public class DeferrableInteractionEvent extends InteractionCreateEvent
Dispatched when a user in a guild interacts with an application command or component. It is recommended you use a subclass in your event listeners to access interaction-specific methods. Application command interactions likeChatInputInteractionEvent,UserInteractionEventandMessageInteractionEventare created through Discord REST API, while component interactions likeButtonInteractionEventandSelectMenuInteractionEventare added to a message as user interface. See a diagram below for the current event hierarchy for interactions.You are required to respond to this interaction within a three-second window by using one of the following:
reply()to directly include a messagedeferReply()to acknowledge without a message, typically to perform a background task and give the user a loading state until it is edited
editReply()to edit the initial responsegetReply()to fetch the initial responsedeleteReply()to delete the initial response
createFollowup()to create a followup messageeditFollowup(Snowflake)to update a followup message, given its IDdeleteFollowup(Snowflake)to delete a followup message, given its ID
This is not directly dispatched by Discord, but is a utility specialization of
InteractionCreateEvent.- See Also:
- Interaction Create

-
-
Constructor Summary
Constructors Constructor Description DeferrableInteractionEvent(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.usedeferReply()insteadMono<Void>acknowledgeEphemeral()Deprecated.migrate todeferReply().withEphemeral(true)discord4j.core.spec.InteractionFollowupCreateMonocreateFollowup()Creates a follow-up message to this interaction.Mono<Message>createFollowup(discord4j.core.spec.InteractionFollowupCreateSpec spec)Creates a follow-up message to this interaction.discord4j.core.spec.InteractionFollowupCreateMonocreateFollowup(String content)Creates a follow-up message to this interaction with the given message content.discord4j.core.spec.InteractionCallbackSpecDeferReplyMonodeferReply()Acknowledges the interaction indicating a response will be edited later.Mono<Void>deferReply(discord4j.core.spec.InteractionCallbackSpec spec)Acknowledges the interaction indicating a response will be edited later.Mono<Void>deleteFollowup(Snowflake messageId)Delete a followup message created under this interaction.Mono<Void>deleteReply()Deletes the initial reply to this interaction.discord4j.core.spec.InteractionFollowupEditMonoeditFollowup(Snowflake messageId)Edits a follow-up message to this interaction.Mono<Message>editFollowup(Snowflake messageId, discord4j.core.spec.InteractionReplyEditSpec spec)Edits a follow-up message to this interaction.discord4j.core.spec.InteractionReplyEditMonoeditReply()Edits the initial reply sent when accepting this interaction.Mono<Message>editReply(discord4j.core.spec.InteractionReplyEditSpec spec)Edits the initial reply sent when accepting this interaction with the given spec contents.discord4j.core.spec.InteractionReplyEditMonoeditReply(String content)Edits the initial reply sent when accepting this interaction with the given message content.InteractionResponsegetInteractionResponse()Returns a REST-only handler for common operations related to an interaction response associated with this event.Mono<Message>getReply()Returns the initial reply to this interaction.discord4j.core.spec.InteractionPresentModalMonopresentModal()Requests to respond to the interaction by presenting a modal for the user to fill out and submit.Mono<Void>presentModal(discord4j.core.spec.InteractionPresentModalSpec spec)Requests to respond to the interaction by presenting a modal for the user to fill out and submit with the given spec contents.Mono<Void>presentModal(String title, String customId, Collection<LayoutComponent> components)Requests to respond to the interaction by presenting a modal for the user to fill out and submit.discord4j.core.spec.InteractionApplicationCommandCallbackReplyMonoreply()Requests to respond to the interaction with a message.Mono<Void>reply(discord4j.core.spec.InteractionApplicationCommandCallbackSpec spec)Requests to respond to the interaction with a message.discord4j.core.spec.InteractionApplicationCommandCallbackReplyMonoreply(String content)Requests to respond to the interaction with a message initialized with the specified content.Mono<Void>reply(Consumer<? super LegacyInteractionApplicationCommandCallbackSpec> spec)Deprecated.usereply(InteractionApplicationCommandCallbackSpec),reply(String)orreply()which offer an immutable approach to build specs-
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
-
DeferrableInteractionEvent
public DeferrableInteractionEvent(GatewayDiscordClient gateway, ShardInfo shardInfo, Interaction interaction)
-
-
Method Detail
-
acknowledge
@Deprecated public Mono<Void> acknowledge()
Deprecated.usedeferReply()insteadAcknowledges the interaction indicating a response will be edited later. The user sees a loading state, visible to all participants in the invoking channel. For an "only you can see this" response, seeacknowledgeEphemeral(), or to include a message,reply(String).withEphemeral(true)- Returns:
- A
Monowhere, 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.
-
deferReply
public discord4j.core.spec.InteractionCallbackSpecDeferReplyMono deferReply()
Acknowledges the interaction indicating a response will be edited later. The user sees a loading state, visible to all participants in the invoking channel. For an "only you can see this" response, addwithEphemeral(true), or to include a message,reply(String).withEphemeral(true).After calling
deferReply, you are not allowed to call other acknowledging or reply method and have to either work with the initial reply usinggetReply(),editReply(),deleteReply(), or using followup messages withcreateFollowup(),editFollowup(Snowflake)ordeleteFollowup(Snowflake).- Returns:
- A
InteractionCallbackSpecDeferReplyMonowhere, 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 it.
-
deferReply
public Mono<Void> deferReply(discord4j.core.spec.InteractionCallbackSpec spec)
Acknowledges the interaction indicating a response will be edited later. The user sees a loading state, visible to all participants in the invoking channel.After calling
deferReply, you are not allowed to call other acknowledging or reply method and have to either work with the initial reply usinggetReply(),editReply(),deleteReply(), or using followup messages withcreateFollowup(),editFollowup(Snowflake)ordeleteFollowup(Snowflake).- Parameters:
spec- an immutable object that specifies how to build the reply message to the interaction- Returns:
- A
Monowhere, 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
@Deprecated public Mono<Void> acknowledgeEphemeral()
Deprecated.migrate todeferReply().withEphemeral(true)Acknowledges the interaction indicating a response will be edited later. Only the invoking user sees a loading state.- Returns:
- A
Monowhere, 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.
-
reply
@Deprecated public Mono<Void> reply(Consumer<? super LegacyInteractionApplicationCommandCallbackSpec> spec)
Deprecated.usereply(InteractionApplicationCommandCallbackSpec),reply(String)orreply()which offer an immutable approach to build specsRequests to respond to the interaction with a message.- Parameters:
spec- AConsumerthat provides a "blank"LegacyInteractionApplicationCommandCallbackSpecto be operated on.- Returns:
- A
Monowhere, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theMono.
-
reply
public discord4j.core.spec.InteractionApplicationCommandCallbackReplyMono reply()
Requests to respond to the interaction with a message. Properties specifying how to build the reply message to the interaction can be set via thewithXxxmethods of the returnedInteractionApplicationCommandCallbackReplyMono.For component interactions, like buttons or select menus, this method will create a new message. If you want to modify the message the component is on, see
ComponentInteractionEvent.edit()orComponentInteractionEvent.deferEdit().After calling
reply, you are not allowed to call other acknowledging or reply method and have to either work with the initial reply usinggetReply(),editReply(),deleteReply(), or using followup messages withcreateFollowup(),editFollowup(Snowflake)ordeleteFollowup(Snowflake).- Returns:
- A
InteractionApplicationCommandCallbackReplyMonowhere, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theInteractionApplicationCommandCallbackMono.
-
reply
public discord4j.core.spec.InteractionApplicationCommandCallbackReplyMono reply(String content)
Requests to respond to the interaction with a message initialized with the specified content. Properties specifying how to build the reply message to the interaction can be set via thewithXxxmethods of the returnedInteractionApplicationCommandCallbackReplyMono.For component interactions, like buttons or select menus, this method will create a new message. If you want to modify the message the component is on, see
ComponentInteractionEvent.edit()orComponentInteractionEvent.deferEdit().After calling
reply, you are not allowed to call other acknowledging or reply method and have to either work with the initial reply usinggetReply(),editReply(),deleteReply(), or using followup messages withcreateFollowup(),editFollowup(Snowflake)ordeleteFollowup(Snowflake).- Parameters:
content- a string to populate the message with- Returns:
- A
InteractionApplicationCommandCallbackReplyMonowhere, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theInteractionApplicationCommandCallbackMono.
-
reply
public Mono<Void> reply(discord4j.core.spec.InteractionApplicationCommandCallbackSpec spec)
Requests to respond to the interaction with a message.For component interactions, like buttons or select menus, this method will create a new message. If you want to modify the message the component is on, see
ComponentInteractionEvent.edit()orComponentInteractionEvent.deferEdit().After calling
reply, you are not allowed to call other acknowledging or reply method and have to either work with the initial reply usinggetReply(),editReply(),deleteReply(), or using followup messages withcreateFollowup(),editFollowup(Snowflake)ordeleteFollowup(Snowflake).- Parameters:
spec- an immutable object that specifies how to build the reply message to the interaction- Returns:
- A
Monowhere, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theMono.
-
presentModal
public discord4j.core.spec.InteractionPresentModalMono presentModal()
Requests to respond to the interaction by presenting a modal for the user to fill out and submit. Once the user submits the modal, it will be received as a newModalSubmitInteractionEvent. Properties specifying how to build the modal can be set via thewithXxxmethods of the returnedInteractionPresentModalMono.- Returns:
- A
InteractionPresentModalMonowhere, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theInteractionPresentModalMono.
-
presentModal
public Mono<Void> presentModal(String title, String customId, Collection<LayoutComponent> components)
Requests to respond to the interaction by presenting a modal for the user to fill out and submit. Once the user submits the modal, it will be received as a newModalSubmitInteractionEvent.- Parameters:
title- The title of the modalcustomId- A developer defined ID for the modalcomponents- A collection of components the modal should contain- Returns:
- A
Monowhere, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theMono.
-
presentModal
public Mono<Void> presentModal(discord4j.core.spec.InteractionPresentModalSpec spec)
Requests to respond to the interaction by presenting a modal for the user to fill out and submit with the given spec contents. Once the user submits the modal, it will be received as a newModalSubmitInteractionEvent.- Parameters:
spec- an immutable object that specifies how to present the modal window- Returns:
- A
Monowhere, upon successful completion, emits nothing; indicating the interaction response has been sent. If an error is received, it is emitted through theMono.
-
editReply
public discord4j.core.spec.InteractionReplyEditMono editReply(String content)
Edits the initial reply sent when accepting this interaction with the given message content.For component interactions, like buttons or select menus, this method modifies the message depending on the initial response method chosen: if
deferReply()orreply()was used, the new message created with the reply; ifComponentInteractionEvent.edit()orComponentInteractionEvent.deferEdit()was used, this method will modify the message the component is on.- Parameters:
content- a string to update the message with- Returns:
- a
InteractionReplyEditMonowhere, upon successful completion, emits the updated message. If an error is received, it is emitted through theInteractionReplyEditMono.
-
editReply
public discord4j.core.spec.InteractionReplyEditMono editReply()
Edits the initial reply sent when accepting this interaction. Properties specifying how to build the edit message request can be set via thewithXxxmethods of the returnedInteractionReplyEditMono.For component interactions, like buttons or select menus, this method modifies the message depending on the initial response method chosen: if
deferReply()orreply()was used, the new message created with the reply; ifComponentInteractionEvent.edit()orComponentInteractionEvent.deferEdit()was used, this method will modify the message the component is on.- Returns:
- a
InteractionReplyEditMonowhere, upon successful completion, emits the updated message. If an error is received, it is emitted through theInteractionReplyEditMono.
-
editReply
public Mono<Message> editReply(discord4j.core.spec.InteractionReplyEditSpec spec)
Edits the initial reply sent when accepting this interaction with the given spec contents.For component interactions, like buttons or select menus, this method modifies the message depending on the initial response method chosen: if
deferReply()orreply()was used, the new message created with the reply; ifComponentInteractionEvent.edit()orComponentInteractionEvent.deferEdit()was used, this method will modify the message the component is on.- Parameters:
spec- an immutable object that specifies how to edit the initial reply- Returns:
- a
Monowhere, upon successful completion, emits the updated message. If an error is received, it is emitted through theMono.
-
getReply
public Mono<Message> getReply()
Returns the initial reply to this interaction.- Returns:
- a
Monowhere, upon successful completion, emits the initial reply message. If an error is received, it is emitted through theMono.
-
deleteReply
public Mono<Void> deleteReply()
Deletes the initial reply to this interaction.- Returns:
- a
Monowhere, upon successful initial reply deletion, emits nothing indicating completion. If an error is received, it is emitted through theMono.
-
createFollowup
public discord4j.core.spec.InteractionFollowupCreateMono createFollowup()
Creates a follow-up message to this interaction. Properties specifying how to build the follow-up message can be set via thewithXxxmethods of the returnedInteractionFollowupCreateMono.- Returns:
- a
InteractionFollowupCreateMonowhere, upon successful completion, emits the resulting follow-up message. If an error is received, it is emitted through theInteractionApplicationCommandCallbackMono.
-
createFollowup
public discord4j.core.spec.InteractionFollowupCreateMono createFollowup(String content)
Creates a follow-up message to this interaction with the given message content.- Parameters:
content- a string to populate the followup message with- Returns:
- a
InteractionFollowupCreateMonowhere, upon successful completion, emits the resulting follow-up message. If an error is received, it is emitted through theInteractionApplicationCommandCallbackMono.
-
createFollowup
public Mono<Message> createFollowup(discord4j.core.spec.InteractionFollowupCreateSpec spec)
Creates a follow-up message to this interaction.- Parameters:
spec- an immutable object that specifies how to build the follow-up message- Returns:
- a
Monowhere, upon successful completion, emits the resulting follow-up message. If an error is received, it is emitted through theMono.
-
editFollowup
public discord4j.core.spec.InteractionFollowupEditMono editFollowup(Snowflake messageId)
Edits a follow-up message to this interaction. Properties specifying how to edit the follow-up message can be set via thewithXxxmethods of the returnedInteractionFollowupEditMono.- Parameters:
messageId- the follow-up message ID to edit- Returns:
- a
InteractionFollowupEditMonowhere, upon successful completion, emits the updated follow-up message. If an error is received, it is emitted through theInteractionFollowupEditMono.
-
editFollowup
public Mono<Message> editFollowup(Snowflake messageId, discord4j.core.spec.InteractionReplyEditSpec spec)
Edits a follow-up message to this interaction.- Parameters:
messageId- the follow-up message ID to editspec- an immutable object that specifies how to build the edited follow-up message- Returns:
- a
Monowhere, upon successful completion, emits the updated follow-up message. If an error is received, it is emitted through theMono.
-
deleteFollowup
public Mono<Void> deleteFollowup(Snowflake messageId)
Delete a followup message created under this interaction.- Parameters:
messageId- the message ID to be deleted- Returns:
- a
Monowhere, upon successful message deletion, returns a completion signal. If an error is received, it is emitted through theMono.
-
getInteractionResponse
public InteractionResponse getInteractionResponse()
Returns a REST-only handler for common operations related to an interaction response associated with this event.- Returns:
- a handler aggregating a collection of REST API methods to work with an interaction response
- See Also:
editReply(),getReply(),deleteReply(),createFollowup(),editFollowup(Snowflake),deleteFollowup(Snowflake)
-
-