Reputation: 31
I am trying to make a bot that deletes a message if a substring is found within it. Someone bypassed it by editing their message. How do I detect when a user edits a message in discord.py rewrite?
Upvotes: 3
Views: 1709
Reputation: 449
First, be sure to update discord.py to v1.5.0 and enable guild messages intent if you haven't already. (For safety, I recommend enabling all intents in both your code and the Discord Developer Portal.)
Now, we make use of the on_message_edit
event, like so:
@bot.event
async def on_message_edit(before, after):
if before.content != after.content:
if 'substring' in after.content:
# do something here
Upvotes: 2