@commands.has_permissions 不检查权限 [英] @commands.has_permissions not checking for permissions
问题描述
所以基本上我正在做的是尝试编写一个非常基本的踢和禁止命令来用于我的不和谐机器人.我浏览了许多不同的教程和类似的问题,但我根本找不到解决方法.
So basically what I am doing is trying to write a very basic kick and ban command to use for my discord bot. I've looked through many different tutorials and similar questions asked, but I simply cannot find a fix to this.
@bot.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, user: discord.Member, *, reason=None):
await ctx.kick(reason=reason)
await ctx.send(f"{user} has been kicked successfully")
当我启动并运行机器人时,每个人都可以踢其他人,无论他们是否有权踢成员,即使我已指定它来检查用户是否能够踢人.我想要这样,如果用户没有踢成员的权限,他们不应该踢任何人.我对编码相当陌生,感谢任何帮助.如果有人想检查我程序中的其余代码,我很乐意发布它,但目前我认为没有理由必须这样做.
When I have the bot up and running, everyone is able to kick everybody else regardless of whether they have permissions to kick members or not, even though I have specified it to check if the user is able to kick people. I want it so that if a user does not have permissions to kick members, they shouldn't be able to kick anyone. I am fairly new to coding, and any help is appreciated. If anyone would like to check for the rest of the code in my program, I am happy to post it, but for now I don't see a reason to have to.
推荐答案
await ctx.kick(reason=reason)
你试图踢出上下文.踢该成员:
You're trying to kick the context. Kick the member instead:
await user.kick(reason=reason)
这篇关于@commands.has_permissions 不检查权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!