@commands.has_permissions not checking for permissions

。_饼干妹妹 提交于 2021-01-28 06:06:08

问题


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.


回答1:


await ctx.kick(reason=reason)

You're trying to kick the context. Kick the member instead:

await user.kick(reason=reason)


来源:https://stackoverflow.com/questions/62055224/commands-has-permissions-not-checking-for-permissions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!