【发布时间】:2021-04-12 12:05:36
【问题描述】:
我想知道是否有一种方法可以记录在一个特定的不和谐服务器中发送的每条消息并将它们记录到一个 txt 文件中。到目前为止我有这个代码,但我认为它只记录正在发送的新消息。我需要它来记录所有内容。
@bot.event
async def on_message(message):
await bot.process_commands(message)
if (message.channel.id == '655864692333477926'):
sentmsg2 = str(message.content)
f=open("speclog.txt", "a+")
for i in range(1):
f.write(sentmsg2 + "\r\n")
【问题讨论】:
-
message.channel.id == '655864692333477926'
channel.id是整数,而不是字符串。和discordpy.readthedocs.io/en/latest/…回答你的问题 -
文档在哪里?
标签: python python-3.x discord discord.py