Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.93k stars 3.77k forks source link

How to use client.add_reaction ? #543

Closed matcool closed 7 years ago

matcool commented 7 years ago

I have looked in the docs, and everywhere, but i cant get add_reaction to work. In my current status, the code is giving this error "discord.errors.HTTPException: BAD REQUEST (status code: 400) ". Please help me ;3;

tylergibbs2 commented 7 years ago

You most likely aren't trying to add an emoji. What is your code?

Also see: http://discordpy.readthedocs.io/en/latest/faq.html#how-can-i-add-a-reaction-to-a-message

matcool commented 7 years ago

elif msw("!addreaction"): await client.add_reaction(message, "<:lenny:305363712599130112>") Notes : msw = message.content.startswith

matcool commented 7 years ago

I also tried message.id

scarletcafe commented 7 years ago

When passing a custom emoji as text, you use name:id.

await client.add_reaction(message, "lenny:305363712599130112")

If this still doesn't work, your bot doesn't have access to the custom emoji.

matcool commented 7 years ago

Still isnt working :/ I just tried : await client.add_reaction(message, "wink:305366787204317185") and await client.add_reaction(message.id, "wink:305366787204317185") Neither worked.

scarletcafe commented 7 years ago

What error are you getting? Is it different from before?

matcool commented 7 years ago

discord.errors.HTTPException: BAD REQUEST (status code: 400): Unknown Emoji

scarletcafe commented 7 years ago

Your bot doesn't have access to whatever emoji you are trying to use. Note that custom emoji for servers will only work in their respective servers under most cases, and your bot may not be able to access the emoji you can. You will likely have to use a different emoji for whatever purpose you need reactions for.

Eternity71529 commented 7 years ago

Use discord.utils.get() to get the Emoji object and pass it in instead of the string (for custom emojis) For normal ones just pass the raw emoji. Eg: 👌

matcool commented 7 years ago

When giving emojis like :ok_hand:, the bot still says its a Unknown Emoji

ghost commented 7 years ago

@MatCorgi You must use the unicode symbol.

scarletcafe commented 7 years ago

Please read the FAQ entry on this because it answers many of your questions surrounding add_reaction.

matcool commented 7 years ago

Well so i have to get some better editor since when i paste a unicode symbol on idle, it crashes.

matcool commented 7 years ago

image finally