Reputation: 9
I have some code
@bot.event
async def on_reaction_add(reaction, user):
print("hello")
if(user.id == bot.user.id):
return
if(not reaction.message.guild):
await reaction.message.delete()
@bot.command(name="dm", brief="Anonymously dms user")
async def dm(ctx, user: discord.Member, *, message=None):
await ctx.message.delete()
if(message is None):
await ctx.send("Enter a message to send to this user!")
return
msg = await user.send("**An anonymous user sent you this:** "+message)
await msg.add_reaction("\U0001F5D1")
on_reaction_add is only being called when my bot initially adds a reaction to it's own message. When I try to add a reaction to the message, hello is not printed into the terminal and there's no error at all either.
Edit: Fixed issue by using on_raw_reaction_add instead of on_reaction_add.
Upvotes: 1
Views: 163
Reputation: 155
on_reaction_add()
requires the message to be in the internal message cache. Try using this instead:
on_raw_reaction_add(payload)
See more information here.
Upvotes: 1