我遇到了SyntaxError,但错误指向没有意义的
我已经尝试过移动代码并在Google中搜索该错误,但没有帮助
@client.command()
@has_permissions(kick_members=True)
async def mute(ctx, member:discord.Member, *, reason=None):
arg=reason
author=ctx.author
guild=ctx.message.guild
perms=discord.Permissions(connect=False, speak=False, read_text_channels_&_see_voice_channels=False, add_reactions=False, send_messages=False)
role=discord.utils.get(ctx.guild.roles, name="muted")
await guild.create_role(name="muted", colour=discord.Colour(0x808080), permissions=perms)
await member.send(f'You got muted for: ```\n{arg}\n``` Muted by: {author}')
await member.add_roles(role)
await ctx.send(f'{member.mention} got muted for: ```\n{arg}\n``` Muted by: {author}!')
错误消息是:SyntaxError:关键字不能是表达式,然后在我放置^的地方以红色突出显示
@client.command()
@has_permissions(kick_members=True)
async def mute(ctx, member:discord.Member, *, reason=None):
arg=reason
author=ctx.author
guild=ctx.message.guild
perms=discord.Permissions(connect=False, speak=False, read_text_channels_&_see_voice_channels=False, add_reactions=False
``` ^
答案 0 :(得分:2)
答案很简单:您在Debug JS Remotely
中有一个&
,我相信您打算以此作为参数的名称。
由于read_text_channels_&_see_voice_channels
不能使用名称,Python将其解析为&
,这与将read_text_channels_ & _see_voice_channels
运算符(二进制和)应用于&
和{{ 1}}。