discord.py - discord.Member.reactions object giving empty list

def e_check(reaction):
  for x in reaction:
    if x in ["\u0031\ufe0f\u20e3", "\u0032\ufe0f\u20e3","\u0033\ufe0f\u20e3","\u0034\ufe0f\u20e3","\u0035\ufe0f\u20e3","\u0036\ufe0f\u20e3","\u0037\ufe0f\u20e3","\u0038\ufe0f\u20e3"]:
      return True

fight_embed = [dm_embed_user1, dm_embed_user2] # dm_embed_user1 = await ctx.send(embed=embed)

for x in figth_embed:
    confirmation = await bot.wait_for("reaction_add", check=e_check(x.reactions), timeout = 15)
    if confirmation:
      print(x.reactions) # it gives empty list
      for emoji in x.reactions:
        print("worked") # it doesn't prints worked as x.reactions is a empty list

these are the reactions on the embed

enter image description here

Why is the x.reactions is an empty list

1 answer

  • answered 2021-05-17 06:24 Mr_Spaar

    dm_embed_user1 and dm_embed_user2 are the messages that you just sent, before you added emojis to them, so getting their reactions will always return an empty list.

    To get the list of reaction, you need to use what wait_for returns. With reaction_add events, confirmation will be a list of two elements:

    • The reaction that was added
    • The member that added a reaction

    Your check is incomplete, it needs two arguments, reaction and user (replace message.author to ctx.author if you're in a command):

    def e_check(reaction, user):
      flag = str(reaction.emoji) in ["\u0031\ufe0f\u20e3", "\u0032\ufe0f\u20e3","\u0033\ufe0f\u20e3","\u0034\ufe0f\u20e3","\u0035\ufe0f\u20e3","\u0036\ufe0f\u20e3","\u0037\ufe0f\u20e3","\u0038\ufe0f\u20e3"]
      return flag and user == message.author

    Finally, your loop would look like this:

    for embed in figth_embed:
        reaction, member = await bot.wait_for("reaction_add", check=e_check(x.reactions), timeout = 15)
        for emoji in reaction.message.reactions:

    PS: If your user doesn't react in time, it will raise a asyncio.TimeoutError.