I'm making a server bot for my server and I want to log all message deletions and edits. It will log into a log channel for staff to see. In the log channel, I want to have the message show what was deleted or what was before the message edit and what was after the edit of the message. How would I have to bot display the deleted or edited message?
@client.event()
async def on_message_delete(ctx):
embed=discord.Embed(title="{} deleted a message".format(member.name), description="", color="Blue")
embed.add_field(name="What the message was goes here" ,value="", inline=True)
channel=client.get_channel(channel_id)
await channel.send(channel, embed=embed)
You can use on_message_delete and on_message_edit as you are using and then you should give the function message not ctx.
Example on_message_delete:
@client.event()
async def on_message_delete(message):
embed=discord.Embed(title="{} deleted a message".format(message.member.name),
description="", color="Blue")
embed.add_field(name= message.content ,value="This is the message that he has
deleted",
inline=True)
channel=client.get_channel(channel_id)
await channel.send(channel, embed=embed)
Example on_message_edit:
@client.event()
async def on_message_edit(message_before, message_after):
embed=discord.Embed(title="{} edited a
message".format(message_before.member.name),
description="", color="Blue")
embed.add_field(name= message_before.content ,value="This is the message before
any edit",
inline=True)
embed.add_field(name= message_after.content ,value="This is the message after the
edit",
inline=True)
channel=client.get_channel(channel_id)
await channel.send(channel, embed=embed)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments