Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction create improvements #294

Merged
merged 9 commits into from
Jun 12, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface InteractionBehavior : KordEntity, Strategizable {
*
* @return [PublicInteractionResponseBehavior] public acknowledgement of an interaction.
*/
suspend fun ackowledgePublic(): PublicInteractionResponseBehavior {
suspend fun acknowledgePublic(): PublicInteractionResponseBehavior {
val request = PublicInteractionResponseCreateBuilder().toRequest()
kord.rest.interaction.createInteractionResponse(id, token, request)
return PublicInteractionResponseBehavior(applicationId, token, kord)
Expand Down
28 changes: 27 additions & 1 deletion core/src/main/kotlin/event/interaction/InteractionCreate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,35 @@ package dev.kord.core.event.interaction

import dev.kord.common.annotation.KordPreview
import dev.kord.core.Kord
import dev.kord.core.event.Event
import dev.kord.core.behavior.interaction.*
import dev.kord.core.entity.interaction.Interaction
import dev.kord.core.event.Event

/**
* This event fires when an interaction is created.
*
*
* Discord currently has one type of interaction,
* [Slash Commands][dev.kord.core.entity.interaction.ApplicationCommand].
*
* The event should be acknowledged withing 3 seconds of reception using one of the following methods:
* * [acknowledgeEphemeral][Interaction.acknowledgeEphemeral] - acknowledges an interaction ephemerally.
* * [acknowledgePublic][Interaction.acknowledgePublic] - acknowledges an interaction in public.
* * [respondPublic][Interaction.respondPublic] - same as public acknowledgement, but an immediate result (message) can be supplied.
* * [respondEphemeral][Interaction.respondEphemeral] - same as ephemeral acknowledgement, but an immediate result (message) can be supplied.
*
* Once an interaction has been acknowledged,
* you can use [PublicInteractionResponseBehavior.followUp] or [EphemeralInteractionResponseBehavior.followUp] to display additional messages.
*
* The resulting follow-up message and its methods may differ based on which method is used.
* * Following up an acknowledgement results in replacing "The bot is thinking" prompt with the follow-up content.
* * Following up a respond results in a completely new message instance.
*
* As such, due to how Discord handles ephemeral acknowledgements,
* a follow-up on a ephemeral acknowledgement will result in an ephemeral message.
*
* In the current iteration, ephemeral messages (regardless of the type) don't support files and/or embeds.
*/
@KordPreview
class InteractionCreateEvent(
val interaction: Interaction,
Expand Down