不和.py通过Nam在特定频道发送消息

2024-09-30 16:20:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我想这样做,当一条消息被删除时,它会发送在日志中被删除的消息

代码:

@bot.event
async def on_message_delete(message):
data = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print("[" + (colored("{}".format(data), 'white')) + "][" + 
  (colored("{}".format(message.server), 'blue')) + " - " + 
  (colored("{}".format(message.channel), 'magenta')) + "] " + 
  (colored("{}".format(message.author), 'cyan', 'on_magenta') + 
  (colored(": {}".format(message.content), 'red'))))
channel = bot.get_channel("logs")
await bot.say(channel, "ALERT: Message Deleted")
await bot.say(channel, "Message {} got deleted by {} in {}".format(message.content, message.author, channel))
await bot.process_commands(message)

Tags: 代码format消息messagedataonbotchannel