Reputation: 943
This is my code -
@client.event
async def on_message_edit(before, after):
channel = client.get_channel(724859369732177953)
guild = client.get_guild(716816535309516840)
embed = discord.Embed(title=f"{guild.name}", description=f"**{before.author.mention} edited a message in - {before.channel.mention}**\n**Old -**\n ```\n {before.content}\n```\n**New -**\n```\n{after.content}\n```", color=0x40cc88,)
embed.set_thumbnail(url=guild.icon_url)
embed.set_footer(text=guild.name)
await channel.send(embed=embed)
return
When I edit a message, the first embed that the bot send s is correct, but it keeps on sending the embeds again and again untit I exit the process, here is the screenshot-
Any help is much appreciated.
Upvotes: 0
Views: 716
Reputation: 131
at the very beginning of your event check if it's triggered by the bot. You can do something like this:
@client.event
async def on_message_edit(before, after):
if before.author == client.user:
return
channel = client.get_channel(724859369732177953)
...
That will return if the bot edited a message. Otherwise it will execute the code as anticipated.
Upvotes: 1