Discord-S.C.U.M icon indicating copy to clipboard operation
Discord-S.C.U.M copied to clipboard

addReaction sends incorrect emoji.

Open SimonNordon4 opened this issue 2 years ago • 2 comments

I'm not sure if this is an issue with Discum or a higher level issue but "addReaction" doesn't react with the exact same emoji.

The emoji code is the same, the emoji hex is the same and the emoji image is the same, yet it's somehow different:

image red = sent by bot green = sent manually

This issue allows you to react twice with the same emoji instead of it being toggled. The top envelope is one sent by the bot, the bottom envelope it the one sent manually.

They're the same but somehow different?

SimonNordon4 avatar Sep 18 '22 09:09 SimonNordon4

I was able to resolve my issue with a workaround but not a good long term solution.

I checked out the put request the bot was sending and the emoji code was:

%E2%9C%89

Looking at the request url of sending it manually I get:

%E2%9C%89%EF%B8%8F

it appears to be a utf variation selector.

By appending the variation selector it works as intended.

SimonNordon4 avatar Sep 18 '22 10:09 SimonNordon4

A long term solution would be parsing the emoji from utf-8 and replacing certain characters. This is what worked for me

def parse_emoji(emoji):
    emoji_2 = emoji.encode('utf-8')
    emoji_2 = str(emoji_2)
    emoji_2 = emoji_2.partition("'")[2]
    emoji_2 = emoji_2.replace("x", "")
    emoji_2 = emoji_2.replace("'", "")
    emoji_2 = emoji_2.replace("\\", "%")
    return emoji_2

To call it

parse_emoji("✉️")

Output

%e2%9c%89%ef%b8%8f

NeutronBlast avatar Sep 20 '22 02:09 NeutronBlast