问题描述
因此,基本上我正在做的是尝试编写一个非常基本的kick and ban命令以用于不和谐的bot.我浏览了许多不同的教程并提出了类似的问题,但是我根本找不到解决方法.
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不检查权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!