fetch all guilds?
Hey guys, I'm creating a dashboard for my Discord bot, but ran into some issues. I'm trying to get a list of all id's from all servers my discord bot is in.
I'm currently using this:
However it only fetches the first 200 and not all of them, so this doesn't work.
I was wondering how Discord.js does it and is able to cache all guilds in the ready event. (Also does it truly get all guilds, even if your bot is in like 2m guilds?)
6 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPAlright thanks, I'm just now learning about sharding, but I'm probably fine for now (~450 guilds)
I think what I'll do for now is create an api endpoint in my bot, then call it from my website to get all guilds. I'll have to think of something better in the future.
Unknown User•6d ago
Message Not Public
Sign In & Join Server To View
That is indeed what I tried to do, but it only works to fetch the first 200 guilds.
I could use pagination to get more, but I feel like that's not a great idea long term.
Unknown User•6d ago
Message Not Public
Sign In & Join Server To View
I have a dashboard with guilds where I'm comparing the guilds my bot is in and the guilds the user is in, then display only the mutual guilds.
Oh yeah true that is indeed better.
But the overall idea of making an api call to my own bot still stays the same right?
Alright thanks for the help!