This code allows edited messages to be logged in another channel on a discord server, however sometimes it takes the sending of GIFs and counts it as an edited message. How do I fix that even though I thought I told it to ignore embeds?
@commands.Cog.listener()
async def on_message_edit(self, message_before, message_after):
if message_before.author == self.client.user: #Checks to see if the author of the edited message wasn't BenBot.
return
elif message_before.author.bot == True: #Checks to see if the author of the edited messages wasn't a bot
return
if len(message_after.embeds)>1: #Checks to see if the message hasn't been edited with an embed.
return
now = datetime.now() #Grabs the current time
current_time=now.strftime("%H:%M:%S") #Formats the current time into a readable form.
current_date=now.strftime("%d/%m/%Y") #Formats the current date into a readable form.
edit_embed=discord.Embed(title = f"Message Edited", description= f'**User:** <@{message_before.author.id}>\n**Channel:** <#{message_before.channel.id}>\n**Server:** {message_before.guild}\n**Message (Before Edit):** \n{message_before.content}\n**Message (After Edit):** \n{message_after.content}\n\n[Jump to This Message]({message_before.jump_url})', color=0x00ff00)
edit_embed.set_footer(text=f"Message ID: {message_before.id}\nDate: {current_date} • Time: {current_time}")
edit_embed.set_author(name =f"{message_before.author}", icon_url=f"{message_before.author.avatar_url}")
archive_edit=self.client.get_channel(789929258184474675) #Grabs the ID of the Edited Messages Channel where the archive is to be stored.
try:
edit_embed.set_image(url=message_after.attachments[0].proxy_url)
except IndexError:
pass
await archive_edit.send(embed=edit_embed) #Sends the edited message