Reputation: 51
I'm currently working on a discord bot, and I was wondering if anyone knew how to display the number of servers the bot is in upon running it in the terminal. Any help would be greatly appreciated. Here is the startup message code (which includes the status code as well):
client.once('ready', () => {
console.log('Bot is online.')
client.user.setStatus('available')
client.user.setPresence({
activity: {
name: 'use code "!help" for commands',
type: 'PLAYING',
url: ''
}
})
}
Upvotes: 1
Views: 883
Reputation: 8402
You can use client.guilds.cache.size
which will return the number of guilds your bot is in.
Example:
console.log(`Bot is online and running in ${client.guilds.cache.size} servers!`)
Upvotes: 2