The way shown above will not work at the time of making this post. That's why I have edited it so that It will.
The line:
embed=discord.Embed(title="{} edited a
message".format(message_before.member.name),
description="", color="Blue")
It does not work as message
does not have the attribute member
. It also does not work because you can not set the colour to Blue
or a string without integer conversion. The best way to do this is by just defining a hex like this enter color=0xFF0000
this makes it red.
The full line changed:
embed = discord.Embed(title="{} deleted a message".format(message.author.name),
description="", color=0xFF0000)
Here are the full two commands edited to work.
@client.event
async def on_message_delete(message):
embed = discord.Embed(title="{} deleted a message".format(message.author.name),
description="", color=0xFF0000)
embed.add_field(name=message.content, value="This is the message that he has deleted",
inline=True)
channel = client.get_channel(channelid)
await channel.send(channel, embed=embed)
@client.event
async def on_message_edit(message_before, message_after):
embed = discord.Embed(title="{} edited a message".format(message_before.author.name),
description="", color=0xFF0000)
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(channelid)
await channel.send(channel, embed=embed)
I would at the top of your code define the channel you would like to use something like this.
logging_channel = channelID
# then at your two commands do this:
global logging_channel