【问题标题】:How do you edit a role permission in discord.py?如何在 discord.py 中编辑角色权限?
【发布时间】:2021-06-22 09:56:00
【问题描述】:

我写了一个小 Python 脚本,它应该为某个角色授予“管理员”权限,只是为了尝试角色编辑的工作原理。这是我的代码:

 @bot.command()
 async def EditRoleTest(ctx):
     await ctx.guild.roles[1].edit("permissions(administrator)")

但是当我尝试运行它时,就会出现以下错误:

discord.ext.commands.errors.CommandInvokeError: 
Command raised an exception: 
TypeError: edit() takes 1 positional argument but 2 were given

那么如何传递我要添加权限管理员的参数呢? 提前致谢。

【问题讨论】:

    标签: permissions arguments discord.py roles


    【解决方案1】:

    编辑角色时,您必须将 discord.Permissions 实例作为关键字参数传递

    role = ctx.guild.roles[1] # Or another role object
    perms = discord.Permissions(administrator=True)
    await role.edit(permissions=perms)
    

    参考:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-15
      • 1970-01-01
      • 1970-01-01
      • 2020-09-24
      • 1970-01-01
      • 2018-12-29
      • 1970-01-01
      • 2017-05-07
      相关资源
      最近更新 更多