Search code examples
pythondiscord.py

Wait for reaction in DMs discord.py


I am trying to make a command that waits for a reaction on a DM and then gets the reaction emoji. I'm using discord.py. My code works in a normal text channel but not in DMs I also am getting no error messages it just doesn't work!

@bot.command()
async def ping(ctx, user: discord.User):
  if user != None:
    if user != ctx.author:
      players = [ctx.author, user]
      for player in players:
        message = await player.send("test")

        await message.add_reaction('👍')
        await message.add_reaction('👎')

        def check(reaction, user):
          return user == player and str(reaction.emoji) in ['👍', '👎']

        response = await bot.wait_for("reaction_add", check=check)
        if str(response[0]) == "👍":
          await player.send(str(response[0]))
        else:
          await player.send("👎")

Many thanks in advance


Solution

  • I was searching for the same problem. I got the solution No one posted here the solution, so Im posting it here.

    intents = discord.Intents(messages=True, message_content=True, guilds=True, reactions=True, members=True)

    client = discord.Client(intents=intents)