Fredney
Fredney

Reputation: 49

How to count how many people is using my bot?

I want to make a bot stats command for my bot. How do I find out how many people are using my bot? Is there a way same as finding out how many guilds the bot is in? (client.guilds.cache.size)

Upvotes: 0

Views: 1512

Answers (3)

Lioness100
Lioness100

Reputation: 8402

You could use:

client.users.cache.size

Not counting bots:

client.users.cache.filter(user => !user.bot).size

Upvotes: 2

Delight
Delight

Reputation: 60

Do

client.user.setActivity(`on ${client.guilds.cache.size} Servers.`, {
    type: "PLAYING",
});

It sets the presence to Playing on x Servers.

Upvotes: -1

Androz2091
Androz2091

Reputation: 3005

You can use client.guilds.cache.map((guild) => guild.memberCount).reduce((p, c) => p + c);. If your bot is on 4 servers of 40 members, it will be 160.

Upvotes: 2

Related Questions