我一直在尝试使用 discord.py 创建一个 kick 命令,但我收到无效语法的错误。
这是我得到的
@client.event
async def on_command_error(ctx, error):
@client.event
async def on_command_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.channel.send("You cant't do that that")
@client.command()
@commands.has_permissions(kick_memebers=True)
async def kick(ctx, user: discord.Member, *, reason=None)
await user.kick(reason=reason)
await ctx.send(f"{user} has been kicked")
当我运行它时,我收到此错误
File "main.py", line 55
async def kick(ctx, user: discord.Member, *, reason=None)
^
SyntaxError: invalid syntax
答案 0 :(得分:0)
您只是在 async 函数之后缺少 :
。
它应该是这样的:
async def kick(ctx, user: discord.Member, *, reason=None):