为静音命令添加权限但遇到错误

Add permissions to a mute command but encountering an error

我正在尝试为静音命令设置权限,但它们不起作用而且我不知道如何修复它们

这是一个非常简单的静音命令,只是我卡住的权限

@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_and_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}!')

错误是: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() got an unexpected keyword argument 'connect' 我确定我会在其他权限方面遇到类似的错误,但我不知道如何解决,有人能帮忙吗?

接受关键字参数的 initialiser for Permissions expects a number, the permission value. Instead of passing the keyword arguments into the initialiser, pass them into the update() 方法。

perms=discord.Permissions()
perms.update(connect=False, speak=False, read_text_channels_and_see_voice_channels=False, add_reactions=False, send_messages=False)