-
Notifications
You must be signed in to change notification settings - Fork 83
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
Safe deferred responding #546
Conversation
…ponse instead of Message
…ctionResponseBehavior
…eInteractionResponseBehavior
Two things I'm not sure about: The naming for Should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems good overall; however you would like to rename FollowUpX to followup to remain consistent with the class name.
core/src/main/kotlin/behavior/interaction/response/InteractionResponseBehavior.kt
Outdated
Show resolved
Hide resolved
The Discord documentation uses the spelling "Followup Messages" (see here) as a noun. It does not use it as a verb anywhere but I would say that the spelling would be "to follow up" for a verb, which would be |
What are your thoughts on this? |
|
|
No, there is no need to do that since the user is expected to keep the og object for interactions just leave it as Unit iirc |
Now I remember why I introduced it in the first place: val deferred = interaction.deferPublicResponse()
val followupable = deferred.delete()
followupable.createEphemeralFollowup { /* ... */ } I then changed it for So there is actually a need to do this but tbh this is kind of an edge case. |
…InteractionResponseBehavior.delete()
I reverted it for |
👍 |
I think we can use |
Sounds good 👍 |
…nteractionResponseBehavior
I went with |
The problem
Right now it is possible to break Kord's type system when using deferred interaction responses, here is an example for this:
The reason for this is that when a followup message is sent after an inital interaction response with type
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE
(deferEphemeralMessage()
) but before using Edit Original Interaction Response to stop the loading animation (edit()
), it takes the place of the original interaction response and ignores the visibility of the followup completely.This way you end up with an
FollowupMessage
object (with a possibly wrong visibility) when you should actually have anMessageInteractionResponseBehavior
.The solution
To avoid these unclear followup semantics for deferred interaction responses, this PR adds an extra step when working with them. It will now be always required to call the Edit Original Interaction Response endpoint before being able to use followups.
The example from above will now look something like this:
As you can see this is very similar to the first example but now the user is forced to call the equivalent for
response.edit { /* ... */ }
to be able to send followups.Changes made to make it safe
defer[Public|Ephemeral]Message()
and replace them withdefer[Public|Ephemeral]Response()
that return the newDeferred[Public|Ephemeral]MessageInteractionResponseBehavior
typeDeferred[Public|Ephemeral]MessageInteractionResponseBehavior.respond()
that essentially does the same asMessageInteractionResponse.edit()
(also takes the same builder type) but has a more accurate name, this 'edit' actually stops the loading animation and responds with the initial response messageDeferredMessageInteractionResponseBehavior
also has adelete()
method that just stops the loading animation without responding, this is not available for ephemeralsDeferredMessageInteractionResponseBehavior
does not support followup messages but extendsInteractionResponseBehavior
(the type the followup functions were defined on), deprecate those and move them into the new typeFollowupableInteractionResponseBehavior
instead, this is now the supertype of everyInteractionResponseBehavior
that still supports followupsOther changes
MessageInteractionResponse
(and public/ephemeral variation) that extendsMessageInteractionResponseBehavior
and also holds aMessage
(analogous toFollowupMessage
andFollowupMessageBehavior
)MessageInteractionResponseBehavior.edit()
now returns the newMessageInteractionResponse
instead ofMessage
(theMessage
is still available via themessage
property)PublicMessageInteractionResponseBehavior.delete()
fromUnit
toFollowupableInteractionResponseBehavior
, it can still be used to send followups, operations on the original message are no longer possible