member object does not contain all members of the guild
class DiscordClient(Client):
async def on_ready(self):
await self.close()
client = DiscordClient(keywork_arg=5)
client.run(token)
for guild in client.guilds:
if guild.id == 12345: # 12345 is an example guild id, in this example the guild shall contain 40 users
for member in guild.members:
print(member.id)
print(member)
Console print of all members ids and names
Console print of only the bots name and id
dpy version 1.2.5
python version 3.7.6
linux debian buster
I'm unable to reproduce this with the latest master branch.
Does this issue occur even if you attempt to print the members while the bot is running?
Have you tried updating to v1.3?
There was an issue on Discord's end with member chunking last night, have you tried restarting your bot when this happened?
Yeah I have it does not work, even tried with a user token also did not work.
Yeah I have it does not work, even tried with a user token also did not work.
hey, I have same issue, what's your discord so we can talk about this?
Have you guys found anything further on this? I am having the same issue where member object only contains a few (or only one) members of each guild. Using discord.py version 1.3.1.
This is not a bug. The members field in the guild object returns the cached users. All the other users must be explicitly downloaded via guild.fetch_members().
@bsalha1 can you provide a working snippet?
EDIT: Here is what I have tried:
class DiscordClient(Client):
async def on_ready(self):
await self.close()
async def do_things(client):
for guild in client.guilds:
print(guild.name)
if int(guild.id) == 12345:
for member in guild.members:
print(0, member.name) # will print only the name of the bot itself
members = await guild.fetch_members(limit=150).flatten()
print(members)
client = DiscordClient(keywork_arg=5)
client.run(token)
asyncio.run(do_things(client))
I get `RuntimeError: Session is closed``from aiohttp/client.