我想创建一个角色,该角色具有从词典中获取的某些特定权限。这是我尝试过的:
for r in x:
role = r['permissions']
perms = discord.Permissions(create_instant_invite=role["create_instant_invite"], kick_members=role["kick_members"], ban_members=role["ban_members"], administrator=role["administrator"], manage_channels=role["manage_channels"], manage_guild=role["manage_guild"], view_audit_log=role["view_audit_log"], add_reactions=role["add_reactions"], priority_speaker=role["priority_speaker"], stream=role["stream"], read_messages=role["read_messages"],send_messages=role["send_messages"], send_tts_messages=role["send_tts_messages"], manage_messages=role["manage_messages"], embed_links=role["embed_links"], attach_files=role["attach_files"], read_message_history=role["read_message_history"], mention_everyone=role["mention_everyone"], external_emojis=role["external_emojis"], connect=role["connect"], speak=role["speak"], mute_members=role["mute_members"], deafen_members=role["deafen_members"], move_members=role["move_members"], use_voice_activation=role["use_voice_activation"], change_nickname=role["change_nickname"], manage_nicknames=role["manage_nicknames"], manage_roles=role["manage_roles"], manage_webhooks=role["manage_webhooks"], manage_emojis=role["manage_emojis"])
await ctx.message.guild.create_role(name=r['name'], permissions=perms, colour=r['colour'].from_rgb(), hoist=r['hoist'], mentionable=r['mentionable'])
,但它总是说__init__收到了意外的参数。这是完整的错误:
TypeError: __init__() got an unexpected keyword argument 'kick_members'
任何帮助将不胜感激..谢谢。
答案 0 :(得分:0)
您应该创建一个没有权限的Permissions
对象,然后使用字典对其进行更新:
perms = discord.Permissions.none()
perms.update(**role)