Skip to content Skip to sidebar Skip to footer

How To Make Bot Status Say Member Count For All The Servers That Its In (discord.py)

Sorry for the long title. I want my bot to tell me how many members that my bot is in a server with in the bot's status. In other words, I want my bot's statues to say Watching [me

Solution 1:

To get the number of servers:

servers = len(client.guilds)

To get the number of members:

members = 0for guild in client.guilds:
    members += guild.member_count - 1# I've added a '-1' because guild.member_count includes all users and bots including your own bot

So, your on_ready() event would look like this:

@client.eventasyncdefon_ready():
    print('Potato Cat is ready :D')

    servers = len(client.guilds)
    members = 0for guild in client.guilds:
        members += guild.member_count - 1await client.change_presence(activity = discord.Activity(
        type = discord.ActivityType.watching,
        name = f'{servers} servers and {members} members'
    ))

Solution 2:

it is changed to client.change_presence

await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f'{len(client.guilds)} servers and {len(client.members)} people')

Solution 3:

   client.event
asyncdefon_ready():
    print('Potato Cat is ready :D')
    client.loop.create_task(status_task())
    

asyncdefstatus_task():
    whileTrue:
        await bot.change_presence(
            activity=discord.Activity(
                type=discord.ActivityType.watching,
                name=f'Prefix: {prefix} | {len(bot.guilds)} server'),
            status=discord.Status.online)
        await asyncio.sleep(1800)

Post a Comment for "How To Make Bot Status Say Member Count For All The Servers That Its In (discord.py)"