首页 > 解决方案 > discord.py - 按名称在特定频道上发送消息

问题描述

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

代码:

@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)

标签: pythondiscord.py

解决方案


推荐阅读