discord / discord-api-docs

Official Discord API Documentation

Home Page:https://discord.com/developers/docs/intro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom emojis break when editing a Webhook or Interaction message

DenverCoder1 opened this issue · comments

Description

When sending an interaction or webhook message, it is currently possible to add any emoji by its identifier (eg. <:upvote:785497101979090944> even if the bot is not in a server containing that emoji.

image

However, when editing a Webhook or Interaction message sent with a custom emoji, unless the bot shares a server with the emoji, the emoji will not show up properly and will appear as plaintext (eg. :upvote:)

image

Steps to Reproduce

Method 1:

  1. Create an interaction response containing an emoji the bot does not share a server with
  2. Edit the interaction message
  3. The emoji no longer gets displayed properly

Method 2:

  1. Send a webhook message containing an emoji the bot does not share a server with
  2. Edit the webhook message
  3. The emoji no longer gets displayed properly

Expected Behavior

Emojis should continue to be displayed properly after editing the message. Any emoji the bot sends should continue to appear as an image and not become text.

Current Behavior

Emojis get converted into plaintext (eg. :upvote:) after editing the message if the bot does not share a server with the emoji.

Screenshots/Videos

Demonstration gif:

emoji-bug-demo

Client and System Information

Stable 113007 (af69096)
Host 0.0.16 Linux 64-Bit (5.15.11-Zen1-1-Zen)

are you sending an authorization header in the edit request? if you are, try not doing that

When I remove the Authorization header, I'm seeing 401 Unauthorized.

The request is to PATCH https://discord.com/api/v9/channels/.../messages/...

ah, you're using the wrong endpoint; you should use Edit Original Interaction Response without an authorization header

I'm aware of that endpoint and it does actually keep the emojis if I use that, however I'm trying to make it so that when someone replies to the message, it will edit it.

I'm not sure if I'm able to get the interaction data necessary for using the endpoint if I just have a listener for new channel messages.

Edit: I could store the message IDs of the interaction responses mapped to the interaction data and then look up the interaction data by its message id later to use Edit Original Interaction Response, but I am trying to avoid having any persistent storage necessary if at all possible. If I could just update the message using only the message data, that would be ideal.

this behaviour makes sense. if you're editing the message as a webhook, you get webhook checks applied, and if you're editing the message as a bot, you get bot checks applied.
I'd assume other webhook-only formatting such as masked links would also break when editing the message as a bot

Ok thanks. I suppose it makes sense.

One more thing though, I assume it is impossible to get an interaction token given its message id, even if the application id and authorization is known?

that's correct - you'd need to store it in your own database, though keep in mind interaction tokens are only valid for 15 minutes. you can create a webhook yourself if you need to be able to edit the message longer than that