feat(discord): Add Ephemeral Support#514
Open
DeanMauro wants to merge 2 commits into
Open
Conversation
Contributor
|
@DeanMauro is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
450ee9d to
169e054
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #515. This PR adds support for ephemeral messages in Discord.
Because Discord's loading state (the initial "thinking..." response produced by
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE) sets the visibility for the entire message and cannot be changed once set, theEPHEMERALmessage flag must be set in the initial response (i.e. inthis.respondToInteraction()). See here for more detail.I've added a hook to the adapter that can conditionally set these flags, for example for particular slash commands.
Slash commands use the
post()method regardless.The result looks like this:
Public
https://github.com/user-attachments/assets/039e13cc-279c-4440-b09a-3ecd3975fd81
Ephemeral
https://github.com/user-attachments/assets/8d5fde57-647d-4055-986a-d4866e9adbd7
Both the loading state and the final message are Ephemeral if the flag is set; public otherwise. Using
postEphemeral()falls back to sending a private DM.Notes
ephemeral: booleanfield in the adapter config but that's too limiting for those who want per-command control.Test plan
Created a public and private slash command and tested with a test app.
Checklist
pnpm validatepasses