正在删除Discord.py中的用户消息

2024-05-16 00:31:32 发布

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

是否有任何方法可以删除由bot本身以外的任何人发送的消息,文档似乎表明这是可能的

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the proper permissions to do so.

但是我找不到一种方法来在on_消息事件触发器中定位消息,是我遗漏了什么还是不可能?


Tags: to方法文档消息permissionsyourbotany
1条回答
网友
1楼 · 发布于 2024-05-16 00:31:32

是的,这应该是可能的。

您需要bot/用户帐户具有“管理邮件”权限。

@client.event
async def on_message(message):
    await client.delete_message(message)

所以,事件会发生

>User sends message
>Bot detects that the user has sent a message
>Bot deletes the message that the user sent

希望您能从中看到用户消息是如何被删除的,只要确保bot/user帐户具有“管理消息”权限即可。

相关问题 更多 >