My goal is to have the bot react to it's own message and then send a reply in that channel if the user who sent the original command reacts as well. Right now the function works if the command is sent in a server channel, but if sent as a direct message to the bot, it doesn't wait for your reaction. By printing the values of user.id and ctx.author.id during the check, I noticed that the bot checks it's own reaction sometimes (user.id returns the bot's id). I'm not sure if this is related because it waits for a reaction from the correct user in server channels regardless.
API Documentation for wait_for() and on_reaction_add
I'd like this function to work in servers and direct messages to the bot, am I missing something? Thanks!
@bot.command()
async def hello(ctx):
msg = await ctx.send(f'Hi {ctx.author.mention}')
await msg.add_reaction('✅')
def check(reaction, user):
print(user.id, ctx.author.id)
return reaction.message.id == msg.id and user.id == ctx.author.id and str(reaction.emoji) == '✅'
try:
reaction, user = await bot.wait_for('reaction_add', timeout=30.0, check=check)
except asyncio.TimeoutError:
pass
else:
await ctx.send('success')