R
R
reven_n12021-01-14 02:20:47
Python
reven_n1, 2021-01-14 02:20:47

How to get a list of all channel members (Discord.py)?

The number of participants on the server is displayed correctly.
But I need a list of them. And I get only those users who are in voice channels.

@client.event
...
            elif message.content.startswith('!m'):  # Show all members -> 
                for guild in client.guilds:
                    for member in guild.members:
                        print(member)
                    print(guild.member_count)
...


Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2021-01-14
@reven_n1

You need to enable members intent.

import discord
intents = discord.Intents.default()
intents.members = True

client = discord.Client(intents=intents)
# или
# bot = commands.Bot(command_prefix='!', intents=intents)

Also in Dev. Portal to enable Privileged Intents for your bot.
Documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question