Provide interaction response message data when using /callback #3350
Replies: 4 comments
-
For non-ephemeral messages, you could just listen for MESSAGE_CREATES on the gateway that have the same interaction id, and I don't get why you would need the message data for ephemeral messages? (they don't get stored) |
Beta Was this translation helpful? Give feedback.
-
Message id of ephemeral message could be useful for handling component interactions, for example |
Beta Was this translation helpful? Give feedback.
-
@artem30801 ah I see, sorry about that. I never used buttons on ephemeral messages so I never thought of that use-case |
Beta Was this translation helpful? Give feedback.
-
Found this, while researching and considering to make a request about it. Using discord.py and have hit this problem multiple times now. Traceback (most recent call last):
File "/home/debian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/discord/app_commands/commands.py", line 861, in _do_call
return await self._callback(self.binding, interaction, **params) # type: ignore
File "/home/debian/zerotwo/cogs/utility.py", line 102, in avatar
await ctx.send(f"{output_emoji} {output_text}", embed=embed)
File "/home/debian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/discord/ext/commands/context.py", line 877, in send
msg = await self.interaction.original_response()
File "/home/debian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/discord/interactions.py", line 374, in original_response
data = await adapter.get_original_interaction_response(
File "/home/debian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/discord/webhook/async_.py", line 218, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message Context: It sends a message, then tries to fetch the original response to have something in return that I can handle with (example: editing response with the known MessageID) however the API returns "Unknown Message" right after sending a successful message to Discord. 🙃 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
It would be super useful to have the
/callback
endpoint return the newly created interaction response, with at least the new message's ID (ephemeral or not, should be treated the same).Why This is Needed
In the case where we are responding to interactions, especially slash command invocations, and needing to keep state for subsequent component interactions on that message, the message ID is the only common value to link on.
To accomplish this today, I thought we could make a GET request to
/@original,
but it appears it only works for non-ephemeral messages (see this comment on #2919). Additionally, this solution would require an additional call to the API after creating the message.Alternatives Considered
Similar to the premises of #2410, a message object could include the last interaction ID that touched it (including the creation of it). Later, an incoming component interaction event handler could use it to validate that an interaction event is acceptable given the last state of the interaction story. This would create a tree effect where new interactions could be easily linked to their "parent" interaction event, effectively providing the data needed to create a linked list of a message's interaction story from start to finish.
I don't know if this is possible given how ephemeral messages work, so I'm including it as a "this would be ideal" request.
Additional Details
Of course, we can do all this on the application side with some extra work: include some unique id in our app state and include it in all the custom_id fields, then link it on subsequent interactions. It would be great to make use of the data Discord (presumably) has available to simplify application code and make for snappier experiences.
Beta Was this translation helpful? Give feedback.
All reactions