在Discord.py中删除用户消息 [英] Deleting User Messages in Discord.py

查看:271
本文介绍了在Discord.py中删除用户消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了机器人本身以外,是否有其他方法可以删除任何人发送的消息,文档似乎表明有可能

Is there any way to delete a message sent by anyone other than the bot itself, the documentation seems to indicate that it is possible


您自己的消息可以在没有任何适当权限的情况下被删除。但是,要删除其他人的邮件,您需要具有适当的权限。

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_message事件触发器中执行的,我是否丢失了某些东西或只是不可能?

But I can't find a way to target the message to do so in an on_message event trigger, am I missing something or is it just not possible?

推荐答案

是的,应该可能。

您需要漫游器/用户帐户具有管理邮件权限。

You need the bot/user account to have the "Manage Messages" permission.

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

因此,事件会发生,例如

So, the event would occur something like

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

希望通过此操作,您应该能够看到如何删除用户消息,只需确保将漫游器/用户帐户作为管理消息权限即可。

Hopefully from this you should be able to see how user messages are deleted, just ensure that the bot/user account as the "Manage Messages" permission.

这篇关于在Discord.py中删除用户消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆