I have a discord bot, and I was just wondering: how do I find out how many guilds the bot is in? So that if I say -guilds
it'll tell me how many guilds it's in.
I'll leave the command up to you, but to get the bot's available guilds, you must use <Client>.guilds
.
This is a collection of guilds so to get the size of a collection all you have to do is <Client>.guilds.size
This information is also on the discord.js docs.
I hope this helps!
- Trifex
In the comments, @NicoHd105 noted that as of discord.js v12, the proper way to retrieve a collection of all guilds a bot is part of is <Client>.guilds.cache
, meaning to get the size of the guilds you must use <Client>.guilds.cache.size
!