我正在为我的discord.py僵尸程序执行kick命令。这是kick命令可能是的一些代码:

    async kick_command(self, ctx, userName: discord.User):
      prefix_used = ctx.prefix
      alias_used = ctx.invoked_with
      text = msg[len(prefix_used) + len(alias_used):]
      if discord.User permissions = "admin":
        try:
          kick(User)
        except Exception as e:
          ee = "Error: " + e
          await ctx.send_message(content=ee)


我很确定if语句和kick(User)是无效的语法。你能帮助我吗?

我的代码:
click here

最佳答案

尝试这个:

@bot.command()
@has_permissions(kick_members=True)
async def kick(self, ctx, Member: discord.Member):
          await bot.kick(Member)

@kick.error
async def kick_error(error, ctx):
   if isinstance(error, MissingPermissions):
       await ctx.send("You don't have permission to do that!")


不要忘记导入has_permissionsfrom discord.ext.commands import has_permissions

10-04 21:09