Cant use add_reaction discord.py (error code: 10014): Unknown Emoji

460 Views Asked by At

I am trying to create a discord bot that analyzes images and returns an appropriate emoji and that works fine but whenever I try to use it as a reactable I get this error:

Traceback (most recent call last):
  File "C:\Users\noahs\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\noahs\OneDrive\Desktop\Bot\bot.py", line 238, in on_message
    await message.add_reaction(reacta)
  File "C:\Users\noahs\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\message.py", line 1220, in add_reaction
    await self._state.http.add_reaction(self.channel.id, self.id, emoji)
  File "C:\Users\noahs\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji

The code I am executing is this:

   file_ = filename
   print("classifying")
   reaction = classify(file_)
   reaction = str(reaction)
   reaction = (reaction.encode('unicode-escape').decode('ASCII'))
   reaction = reaction[:-2]
   print(reaction)
   await message.add_reaction(reaction)

and the code works perfectly always outputting something like this:

classifying
\U0001f30f

and I get the Unicode of a valid emoji but when I use it with the add_reaction corountine I get the error, I have no idea what could be causing this as I have a valid Unicode emoji as a string specified but I've spent hours fiddling and I just can't figure it out. (note: please do not suggest using the raw emoji that causes an entirely different htttp error)

0

There are 0 best solutions below