1
votes

having trouble getting my discord bot to list all the members of the only guild it's added to..

async def on_ready(self):
    print("logged in as {0}".format(self.user))
    
    guilds = self.guilds        
    print("guilds: " + str(guilds))

    guild = self.get_guild(my_guild_id)
    print("guild members: " + str(guild.members))

The interesting thing is that when i print out the guild itself it shows a member count of 5 (which is correct). However when instantiate the Guild object, and access the members property, it only shows the bot user itself as the member.

guild members: [<Member id=12345678 name='testapp1_bot' discriminator='0683' bot=True nick=None guild=<Guild id=12345 name="ethandrower's server" shard_id=None chunked=False member_count=5>>]
guilds: [<Guild id=12345 name="ethandrower's server" shard_id=None chunked=False member_count=5>]

I'm guessing this either my misunderstanding of the architecture of 'guilds' or a permissions on the bot thing. I've added the bot to the server with full administrator access, so I'm a little stumped as to why I can see the proper count of members, but not the Member objects themselves?

Any help would be greatly appreciated!

1

1 Answers

2
votes

If you're using the latest version of discord.py i.e. 1.5.0, you will need to enable Member intent and apply it to your bot.

How to enable Member Intent: https://discordpy.readthedocs.io/en/latest/intents.html#privileged-intents

Read More about Intents: https://discordpy.readthedocs.io/en/latest/intents.html