Skip to content
Advertisement

How to log reaction removes to another channel? Discord.py

I have reaction adds working perfectly fine. However, when I try to do reaction removes, nothing happens. No error messages or anything.

@client.event
async def on_reaction_remove(reaction, user):
    message = reaction.message
    channel = message.guild.get_channel(bot_logs)
    embed=discord.Embed(title="**{} removed a reaction to a message**".format(message.author.name), description="", color=0xffa500)
    embed.add_field(name="**This is the channel the message reaction was removed in:**", value=str(message.channel), inline=False)
    embed.add_field(name="**This is the message that had a reaction removed:**", value=message.content, inline=True)
    embed.add_field(name="**This was the emoji reaction that was removed:**", value=str(reaction), inline=True)
    await channel.send(embed=embed)

This is the code I am using. Any help would be appreciated!

Advertisement

Answer

This event is only called when the message can be found in the internal message cache.

Source: https://discordpy.readthedocs.io/en/latest/api.html#discord.on_reaction_remove

Ensure you’re testing this on a message that was sent after the bot started up.

Optionally you could switch to using on_raw_reaction_remove since that event is called whether or not the message is in the cache. However, this event requires the reactions gateway intent in your bot.


After debugging and analyzing the library source code, version 1.5.0 – 1.6.0 and will return _get_reaction_user as None and not fire the on_reaction_remove event, which seems to be a bug in Discord.py. Enabling server members intent was not helpful. A Github issue can be found describing the behaviour: https://github.com/Rapptz/discord.py/issues/5867 Rolling back to version 1.4.2 can work if using on_raw_reaction_remove is not an option.

Advertisement