uoǝʌʎǝlפ
uoǝʌʎǝlפ
DIAdiscord.js - Imagine an app
Created by uoǝʌʎǝlפ on 5/14/2025 in #djs-questions
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:
const promise = (async (): Promise<{ data: Guild[] }> => {
const response = await axios.get<Guild[]>(`${DISCORD_API_URL}/users/@me/guilds`, {
headers: { Authorization: `Bot ${TOKEN}` },
});
const promise = (async (): Promise<{ data: Guild[] }> => {
const response = await axios.get<Guild[]>(`${DISCORD_API_URL}/users/@me/guilds`, {
headers: { Authorization: `Bot ${TOKEN}` },
});
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?)
12 replies