【发布时间】:2021-07-02 22:36:21
【问题描述】:
我之前问过这个问题,但由于我对堆栈溢出的经验几乎为零,所以它搞砸了。所以我会用 anwser 重写这个问题,这样寻找这个的人就可以马上得到它。
所以我的问题是,我如何才能将角色列入白名单以防止被禁止。现在稍后,随着对 discord.py 的更多经验,我可以告诉你下面列出的答案是这样做的方法。
工作代码:感谢 CaptAngryEyes
@bot.command()
async def ban(ctx, member : discord.Member):
whitelisted_roles = [728345678923456, 923478569378456, 8923475627893456] # Put the role IDs here
for role in member.roles:
if role.id in whitelisted_roles:
await ctx.send("You can't ban this user! He is a moderator!")
return
else:
# Ban code goes here...
pass
【问题讨论】:
-
如果没有最小的代码工作示例,将很难为您提供帮助。
标签: python discord discord.py whitelist