0
votes

I am trying to generate a list of all of the members in a discord server using discord.py. Here is my code:

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")

However, the result is not only the name of each member, but also the user id, information about guild and a bunch of other stuff. How could I narrow this down to only the names of people in a discord server.

1

1 Answers

0
votes

Try using member.name like so:

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")