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

Add Acknowledge function to ApplicationCommandInteractionCreate for HTTP server interactions #409

Merged
merged 10 commits into from
Jan 20, 2025

Conversation

BowsiePup
Copy link
Contributor

This pull request introduces a new function to ApplicationCommandInteractionCreate

ApplicationCommandInteractionCreate.Acknowledge()

Additions:

New Interaction Response Type:

InteractionResponseTypeAcknowledge. A Strictly internal iota to identify this response type.

New function:

ApplicationCommandInteractionCreate.Acknowledge(). This method is used to respond to the original HTTP request from discord with StatusAccepted (202).
This is not like ApplicationCommandInteractionCreate.DeferCreateMessage(). You are still required to respond with a new HTTP request within 3 seconds to respond to the interaction.
Unlike ApplicationCommandInteractionCreate.CreateMessage(), you are able to access the response which will contain error or the sent message when you send event.Client().Rest().CreateInteractionResponse()

Source to this can be found here
If you send this request for an interaction received over HTTP, respond to the original HTTP request with a 202 and no body.

This is the preferred way to respond to Interactions as you can receive the message created in the response if u need it and errors.

Copy link
Member

@topi314 topi314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good addition. Can you also add the Acknowledge method to the other interaction events?

discord/interaction_response.go Outdated Show resolved Hide resolved
events/interaction_events.go Show resolved Hide resolved
httpserver/server.go Outdated Show resolved Hide resolved
@BowsiePup
Copy link
Contributor Author

All requested changes have been added.

Autocomplete does not as it does not have a Interaction Callback Type and you are expected to respond via the http response on the original request.

@BowsiePup BowsiePup requested a review from topi314 January 18, 2025 23:03
events/interaction_events.go Outdated Show resolved Hide resolved
@BowsiePup BowsiePup requested a review from topi314 January 18, 2025 23:43
@BowsiePup
Copy link
Contributor Author

A few issues fixed:

Auto complete does have an interaction type: APPLICATION_COMMAND_AUTOCOMPLETE_RESULT 8
Added the function to AutocompleteInteractionCreate

Moved InteractionResponseTypeAcknowledge out of the iota const as it broke the iota making all items be one extra then they should be. I moved it out to keep the iota + 1 so it still matches with discord docs.

@topi314
Copy link
Member

topi314 commented Jan 20, 2025

thanks

@topi314 topi314 merged commit 69944d0 into disgoorg:master Jan 20, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants