Discord bot 检查用户是否为管理员
问题描述
您好,我是不和谐的 python 编码新手,我试图创建一个命令来告诉用户他们是否是管理员,但是很好......它一点也不工作
Hi i'm new to python coding with discord and I have tried to make a command that tells the user if they are a admin or not but well... its not working in the slightest
然后当我尝试输入 whoami 时得到这个
I then get this when I try to type whoami
推荐答案
改变
到
然后你可以使用ctx
来获取各种东西,比如写它的用户,消息内容等等
Then you can use ctx
to get all kinds of stuff like the user that wrote it, the message contents and so on
要查看 User
是否是管理员,请执行以下操作if ctx.message.author.server_permissions.administrator:
如果用户是管理员,则应该返回 True
To see if a User
is an administrator do
if ctx.message.author.server_permissions.administrator:
which should return True
if the user is an an Administator
您的代码应如下所示:
这篇关于Discord bot 检查用户是否为管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!