Moondancer
Moondancer

Reputation: 133

Can't get all Members in Guild

I am trying to program a bot, which resets the nickname of all members with a specific name. But I can't get all members but only 11. This is my code:

@tasks.loop(seconds=60)
async def nick():
  for guild in client.guilds:
    print(len(guild.members))
    for member in guild.members:
        print(member.display_name.lower())
        if "uwe" in member.display_name.lower() or "baumfäller" in member.display_name.lower():
          print("yup")
          await member.edit(nick=None)
        await aio.sleep(0.05)

I can't find anything that's wrong and the for member in guild.members: is also in the documentation. (The bot is only in one server so I use for guild in client.guilds)

Upvotes: 1

Views: 796

Answers (1)

pjones123
pjones123

Reputation: 396

This is most likely due to discord's recent API update involving gateway intents. In order to be able to access (non-cached) members of a guild, you have to enable privileged gateway intents for the members intent. Take a look at this

Upvotes: 3

Related Questions