上面显示的方式在发布这篇文章时不起作用。这就是我编辑它的原因。
行:
embed=discord.Embed(title="{} edited a
message".format(message_before.member.name),
description="", color="Blue")
它不起作用,因为message 没有属性member。它也不起作用,因为您不能将颜色设置为 Blue 或没有整数转换的字符串。最好的方法是定义一个像这样的十六进制输入 color=0xFF0000 这使它变成红色。
整行已更改:
embed = discord.Embed(title="{} deleted a message".format(message.author.name),
description="", color=0xFF0000)
以下是完整的两个编辑命令。
@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)
我会在您的代码顶部定义您想要使用的频道。
logging_channel = channelID
# then at your two commands do this:
global logging_channel