Class InteractionCreateEvent
- java.lang.Object
-
- discord4j.core.event.domain.Event
-
- discord4j.core.event.domain.interaction.InteractionCreateEvent
-
- Direct Known Subclasses:
ComponentInteractEvent
,SlashCommandEvent
@Experimental public class InteractionCreateEvent extends Event
Dispatched when a user in a guild uses a Slash Command or clicks a Button.This event is dispatched by Discord.
- See Also:
- Interaction Create
-
-
Constructor Summary
Constructors Constructor Description InteractionCreateEvent(GatewayDiscordClient gateway, ShardInfo shardInfo, Interaction interaction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<Void>
acknowledge()
Acknowledges the interaction indicating a response will be edited later.Mono<Void>
acknowledgeEphemeral()
Acknowledges the interaction indicating a response will be edited later.protected Mono<Void>
createInteractionResponse(InteractionResponseType responseType, discord4j.discordjson.json.InteractionApplicationCommandCallbackData data)
Interaction
getInteraction()
Gets theInteraction
associated with the event.InteractionResponse
getInteractionResponse()
Gets a handler for common operations related to an interaction followup response associated with this event.Mono<Void>
reply(String content)
Requests to respond to the interaction with onlycontent
.Mono<Void>
reply(Consumer<? super InteractionApplicationCommandCallbackSpec> spec)
Requests to respond to the interaction with a message.Mono<Void>
replyEphemeral(String content)
Requests to respond to the interaction with onlycontent
andephemeral set to true
.-
Methods inherited from class discord4j.core.event.domain.Event
getClient, getShardInfo
-
-
-
-
Constructor Detail
-
InteractionCreateEvent
public InteractionCreateEvent(GatewayDiscordClient gateway, ShardInfo shardInfo, Interaction interaction)
-
-
Method Detail
-
getInteraction
public Interaction getInteraction()
Gets theInteraction
associated with the event.- Returns:
- The
Interaction
associated with the event.
-
createInteractionResponse
protected Mono<Void> createInteractionResponse(InteractionResponseType responseType, @Nullable discord4j.discordjson.json.InteractionApplicationCommandCallbackData data)
-
acknowledge
public Mono<Void> acknowledge()
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 a "only you can see this" response, seeacknowledgeEphemeral()
, or to include a message,replyEphemeral(String)
- 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()
Acknowledges the interaction indicating a response will be edited later. Only the invoking user sees a loading state.- 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
.
-
reply
public Mono<Void> reply(String content)
Requests to respond to the interaction with onlycontent
.- Parameters:
content
- A string message to populate the message with.- 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
. - See Also:
InteractionApplicationCommandCallbackSpec.setContent(String)
-
replyEphemeral
public Mono<Void> replyEphemeral(String content)
Requests to respond to the interaction with onlycontent
andephemeral set to true
. Only the invoking user can see it.- Parameters:
content
- A string message to populate the message with.- Returns:
- A
Mono
where, upon successful completion, emits nothing; indicating the ephemeral interaction response has been sent. If an error is received, it is emitted through theMono
. - See Also:
InteractionApplicationCommandCallbackSpec.setContent(String)
,InteractionApplicationCommandCallbackSpec.setEphemeral(boolean)
-
reply
public Mono<Void> reply(Consumer<? super InteractionApplicationCommandCallbackSpec> spec)
Requests to respond to the interaction with a message.- Parameters:
spec
- AConsumer
that provides a "blank"InteractionApplicationCommandCallbackSpec
to be operated 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
.
-
getInteractionResponse
public InteractionResponse getInteractionResponse()
Gets a handler for common operations related to an interaction followup response associated with this event.- Returns:
- A handler for common operations related to an interaction followup response associated with this event.
-
-