简体   繁体   English

已删除的消息日志记录不起作用 discord.py

[英]Deleted messages logging not working discord.py

I want to create an event which prints any deleted message我想创建一个事件来打印任何已删除的消息

here is my code这是我的代码

@client.event
async def on_message_delete(message):
    print(message)

This doesn't print anything and there aren't any errors这不会打印任何内容,也没有任何错误

Maybe this has something to do with intents?也许这与意图有关?

The correct way to make the deleted message get printed would be:打印已删除邮件的正确方法是:

@client.event
async def on_message_delete(message):
    print(message.content)

message.content contains the content of the message which gets printed upon deletion of the message. message.content包含在删除消息时打印的消息内容。

If the message is not found in the internal message cache, then this event will not be called.如果在内部消息缓存中找不到该消息,则不会调用此事件。 This means that your bot must be running before the message that will be removed is sent.这意味着在发送要删除的消息之前,您的机器人必须正在运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM