DiscordChatExporter icon indicating copy to clipboard operation
DiscordChatExporter copied to clipboard

Expose custom emoji URL when used in a message

Open luuk00000000000000000000000000000000000 opened this issue 5 years ago • 8 comments

The custom emoji is shown with it's full image in the HTML output, but in the JSON output there is no way to find the url of the custom emoji.

I will work on this issue.

cynferdd avatar Oct 26 '20 14:10 cynferdd

I just checked, and I see full urls when doing a json output. It doesn't seem to be bugged. It appears to work correctly for me. Please find attached two examples. discord_export_example.zip

cynferdd avatar Oct 26 '20 14:10 cynferdd

@Gladuin can you clarify?

Tyrrrz avatar Oct 26 '20 15:10 Tyrrrz

@Gladuin can you clarify?

In the HTML output, custom emojis are shown in the message as an image, like a normal emoji. However, in the JSON output, custom emojis are shown as (example) :longcat:, with no way of getting the custom emoji's URL / image.

Hmm. That would be because the emojis are parsed separately. The only way to solve this that I can see is by adding something like:

"message": {
    "content": "Message with custom emoji :longcat:",
    "emojiMap": {
         ":longcat:": "url"
     }
}

Tyrrrz avatar Oct 26 '20 16:10 Tyrrrz

Hmm. That would be because the emojis are parsed separately. The only way to solve this that I can see is by adding something like:

"message": {
    "content": "Message with custom emoji :longcat:",
    "emojiMap": {
         ":longcat:": "url"
     }
}

I had something like this in mind too

Any update on this? Just noticed this myself. The problem is that all emoji have a fixed URL, (https://cdn.discordapp.com/emojis/669393875286360084.webp), but the emoji ID is stripped from the JSON output, so there's no way for consuming applications to know. That is, https://github.com/Tyrrrz/DiscordChatExporter/blob/master/DiscordChatExporter.Core/Exporting/Writers/JsonMessageWriter.cs uses PlainTextMarkdownVisitor, instead of preserving

Here's an example of a custom emoji as returned by discord:

"content": "ok, so we know her Lore is dealing with these <:lambda:669393875286360084>-anomalies..."

Which can be resolved by requesting the URL https://cdn.discordapp.com/emojis/669393875286360084.png (or .webp)

But this is JSON outputted by DiscordChatExporter:

"content": "ok, so we know her Lore is dealing with these :lambda:-anomalies...",

As you can see, the JSON exported by DiscordChatExporter is useless for determining which Emoji to request (or whether an emoji is even referenced at all!). Especially since custom emoji may come from potentially-unaccessible private discord servers.

Since users are expected to have some amount of tech savvy to consume the JSON output of message, using PlainTextMarkdownVisitor is inappropriate for JSON output, because it gets rid of a lot of potentially-important metadata in discord's formatting. Instead, JSON output should save the entire un-parsed Discord message, so that downstream consumers can parse it losslessly, and no data is thrown away. Alternatively, if you think it's really important to keep backwards compatibility with this small change, you can add a new key to store this unparsed, lossless data (rawContent?).

nightpool avatar Apr 11 '22 06:04 nightpool

I think the end user shouldn't need to assemble the URLs manually and there should be some sort of emoji mapping object that they would be able to access instead.

Tyrrrz avatar Apr 11 '22 07:04 Tyrrrz

Closing as out of scope because the project no longer accepts new features

Tyrrrz avatar Feb 15 '23 21:02 Tyrrrz