discord.py - 获取公会的所有可用角色

discord.py - Getting all available roles of a guild

我注意到 Guild 对象有一个方法可以获取公会的所有角色。我的问题是我无法使用 pip 安装 discord.py==1.3.0 discord.py==1.2.3中的所有公会角色还有其他方法吗?

在此处下载:https://pypi.org/project/discord.py/#files 并按照说明导入

Returns a list of the guild’s roles in hierarchy order.

The first element of this list will be the lowest role in the hierarchy.

获得角色列表后,您可以遍历它并获取其名称、ID 等。

Documentation