【发布时间】: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 来获得机器人的成员,但我没有获得任何顶级角色。有什么修复吗?
【问题讨论】:
所以现在我的设置是
if memb.id != 'EzLife#9391' and memb.id != message.guild.owner.id and memb.top_role < client.top_role:
但问题是客户端是机器人,而机器人没有顶级角色。我试图通过执行 client.me.top_role 来获得机器人的成员,但我没有获得任何顶级角色。有什么修复吗?
【问题讨论】:
截至目前,在最新版本的 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.name、top_role.id 等。
您可以在此处查看文档:https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.top_role
您也可以加入 discordpy discord 以获得更多帮助:https://discord.com/invite/r3sSKJJ
【讨论】: