【问题标题】:How would I get the top role of a bot(client) in discordpy我如何在不和谐中获得机器人(客户端)的最高角色
【发布时间】:2021-02-03 02:36:51
【问题描述】:

所以现在我的设置是

       if memb.id != 'EzLife#9391' and memb.id != message.guild.owner.id and memb.top_role < client.top_role:

但问题是客户端是机器人,而机器人没有顶级角色。我试图通过执行 client.me.top_role 来获得机器人的成员,但我没有获得任何顶级角色。有什么修复吗?

【问题讨论】:

    标签: python discord bots roles


    【解决方案1】:

    截至目前,在最新版本的 discord.py 中,没有client.me 不过,您可以执行以下操作(使用 discord.ext's commands):

    member = ctx.guild.get_member(client.user.id)
    top_role = member.top_role
    

    top_role 将返回discord.Role,所以你可以做top_role.nametop_role.id 等。

    您可以在此处查看文档:https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.top_role

    您也可以加入 discordpy discord 以获得更多帮助:https://discord.com/invite/r3sSKJJ

    【讨论】:

      猜你喜欢
      • 2021-04-23
      • 2022-09-27
      • 1970-01-01
      • 2021-03-31
      • 1970-01-01
      • 2021-01-22
      • 2020-11-08
      • 2019-02-02
      • 2020-12-15
      相关资源
      最近更新 更多