I'm trying to make a selection screen with two options (two reactions) which the user can react to, and the bot will now what reaction did the user chose

I've tried comparing
reaction != "????" or reaction != "βœ‹" Also tried: reaction != u"\U0001F44C" or reaction != u"\u270B" using the unicode. Also tried the same code with reaction.emoji, str(reaction / reaction.emoji). Also tried comparing the id of the emojis but reaction.emoji.id raise an exception saying that reaction.emoji is a str and strings doesn't have id (because idk why it returns a str instead of a emoji object) I've read the docs and it says it supports != operations but I don't know what to compare

async def on_reaction_add(reaction,user):
     print(reaction) #It prints the two emojis on my console (???? and βœ‹)
     if user.bot:
        print('I am a bot')
     if reaction != "????" or reaction != "βœ‹":
        print('Did not found the emoji')
        print('Found the emoji')
#And then some code which will decide if the user that reacted is valid and what to do with it

#The embed the user have to react to if this helps
embed = discord.Embed(title = 'VS',color=0x00fff5)
        embed.set_author(name = message.author.name,icon_url=message.author.avatar_url)
        embed.set_footer(text = message.mentions[0].name , icon_url = mensaje.mentions[0].avatar_url)
        response = await message.channel.send(embed = embed)
        await response.add_reaction("????") #OK emoji
        await response.add_reaction("βœ‹") #STOP emoji

I expect the bot to recognize the emojis but don't know how.

The docs here definitely suggest it is str(reaction.emoji) == 'πŸ‘' as you tried. I am wondering if this line if str(reaction.emoji) != "πŸ‘Œ" or str(reaction.emoji) != "βœ‹": can ever evaluate to False though. Could you try something simpler like if str(reaction.emoji) == "πŸ‘Œ": print("OK reaction found") – kcontr
You should almost certainly be using Client.wait_for instead of on_reaction_add – Patrick Haugh

1 Answers



  1. switch or for and
  2. use str(reaction.emoji) (see example in the discordpy docs)


De Morgan's Laws would say that

if str(reaction.emoji) != "πŸ‘Œ" or str(reaction.emoji) != "βœ‹":

is the same as writing

if not (str(reaction.emoji) ==  "πŸ‘Œ" and str(reaction.emoji) == "βœ‹"):

and since the reaction cannot be both an OK and a STOP at the same time, that if statement always comes back True and "Did not find the emoji" is always printed.

Something like

     if str(reaction.emoji) != "πŸ‘Œ" and str(reaction.emoji) != "βœ‹":
        print('Did not found the emoji')
        print('Found the emoji')

would work.

EDIT: A slightly more readable solution IMHO would be to check for the presence of the emoji in a set.

     if str(reaction.emoji) not in { "πŸ‘Œ", "βœ‹"}:
        print('Did not find the emoji')
        print('Found the emoji')