使用discord.py获取Discord服务器中所有成员的列表时出现问题

时间:2020-08-07 12:52:02

标签: python list discord discord.py discord.py-rewrite

我正在尝试使用discord.py生成discord服务器中所有成员的列表。这是我的代码:

import discord

client = discord.Client()
@client.event
async def on_ready():
    people = set(client.get_all_members())
    print(people)

client.run("not about to show u my token lol")

但是,结果不仅是每个成员的姓名,而且还包括用户ID,有关行会的信息以及许多其他内容。我如何才能将其缩小到不和谐服务器中的人员姓名。

1 个答案:

答案 0 :(得分:0)

尝试像这样使用member.name

import discord


def get_member_names():
    for guild in client.guilds:
        for member in guild.members:
            yield member.name


client = discord.Client()
@client.event
async def on_ready():
    people = set(get_member_names())
    print(people)

client.run("not about to show u my token lol")