Discord Bot Python 消息日志

Discord Bot Python message logs

嗨,所以我需要在 python 中创建一个 discord 机器人,它在单独的频道中存储特定用户发送的消息。基本上就像消息日志,但它只针对一个用户,他们发送的每条消息都已删除或未删除 如果有人能告诉我如何做到这一点,那将意味着很多

虽然我同意 Elitezen 的评论,但答案很简单。


import discord
from discord.ext import commands

client = commands.Bot(command_prefix=<YOUR PREFIX>)

@client.event
async def on_message(message):
    if message.author.id == <ID OF USER>:
        with open("log.txt","a") as f:
            f.write(message.content + "\n")

client.run(TOKEN)