Discord.py ban 命令错误:NameError: name 'client' is not defined

时间:2021-03-20 01:47:20

标签: python discord.py

我尝试使用 discord.py 创建踢出和禁止命令,但它返回此错误。

Traceback (most recent call last):
  File "main.py", line 58, in <module>
    @client.command()
NameError: name 'client' is not defined
 
KeyboardInterrupt


代码是这样的:

@client.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, user: discord.Member, *, reason=None):
  await user.kick(reason=reason)
  await ctx.send(f"{user} have been kicked sucessfully")

谢谢, 卡西代码

1 个答案:

答案 0 :(得分:-1)

@bot.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, user: discord.Member, *, reason=None):
  await user.kick(reason=reason)
  await ctx.send(f"{user} have been kicked sucessfully")

尝试使用 bot 而不是 client