discord icon indicating copy to clipboard operation
discord copied to clipboard

Send discord emojis in text from matrix to discord

Open XHawk87 opened this issue 1 year ago • 5 comments

I have this bridge on my matrix server, and I have it set up to puppet my discord account. I was trying out direct messages with a friend to see how it works. It's great in most respects, but one key thing that's missing is the ability to use my own discord emojis in chat messages. I wanted to open up a discussion about if/how this can be implemented. I'm a software developer, and I'd be willing to pitch in to help make this happen.

XHawk87 avatar Apr 27 '23 21:04 XHawk87

It seems to me like the correct way to handle this would be to detect <img data-mx-emoticon/> tags in org.matrix.custom.html messages, and have the discord puppet replace these with the matching discord emoji if found, or just send the image link if not. Any thoughts on using this approach?

XHawk87 avatar May 04 '23 08:05 XHawk87

According to https://discord.com/developers/docs/reference#message-formatting

Type Structure Example
Custom Emoji <:NAME:ID> <:mmLol:216154654256398347>
Custom Emoji (Animated) <a:NAME:ID> <a:b1nzy:392938283556143104>

So we'll need to get the emoji ID somehow.

XHawk87 avatar May 04 '23 11:05 XHawk87

For reference, this is how spoiler tags are currently handled: https://github.com/mautrix/go/blob/ac3d88b512f26cee04d90eb8b6c47ce5ebec750b/format/htmlparser.go#L232 https://github.com/mautrix/go/blob/ac3d88b512f26cee04d90eb8b6c47ce5ebec750b/format/htmlparser.go#L307 https://github.com/mautrix/go/blob/ac3d88b512f26cee04d90eb8b6c47ce5ebec750b/format/htmlparser.go#L60 https://github.com/mautrix/discord/blob/7655ff1a648e6312203623ff4bcc3ab85653cc18/formatter.go#L204

This seems like an appropriate place to set up conversion of matrix emoticons tags to discord tags

XHawk87 avatar May 10 '23 08:05 XHawk87

It would also be possible to include Discord's custom emoticons by including it in the 'server' space, as defined in MSC 2545.

HonbraDev avatar Jun 11 '23 14:06 HonbraDev

You could retrieve all emotes from a Discord guild using the Discord API (https://discord.com/developers/docs/resources/emoji), and then upload them to the respective space using the State Event: im.ponies.room_emotes. This feature is supported by certain clients such as Cinny and FluffyChat.

You could simply add an extra prefix to the emotes for identification on the Matrix side, for example, "discord_emotename"

Spaenny avatar Mar 24 '24 19:03 Spaenny

for what it's worth, if your client supports text reactions, and you know the name and id of the emote on discord, you can send the emote as a reaction from matrix with

/react :emotename:123456789

Spacefreak18 avatar Oct 14 '24 00:10 Spacefreak18