'How do you use the Discord API to find server member count for OTHER servers?

How would i use python to find the server count for other servers? One's I'm not a part of? I can figure it out for my own, but not for others.



Solution 1:[1]

You will need to have the server's guild ID for this. You can then fetch the guild from the discord API using fetch_guild() and then access the guild's member_count attribute.

async def get_guild_members(guild_id: int):
    guild = bot.fetch_guild(guild_id)
    
    return guild.member_count

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 leftomash