@discordjs/rest question

Hi everyone, I have this code right here
const botGuilds = await rest
.get(Routes.userGuilds({ after: allBotGuilds[199 * (i + 1)]?.id }))
.catch((err) => {
console.log(err);
return;
});
const botGuilds = await rest
.get(Routes.userGuilds({ after: allBotGuilds[199 * (i + 1)]?.id }))
.catch((err) => {
console.log(err);
return;
});
but for some reason, the after parameter is not being followed. I logged allBotGuilds[199 * (i + 1)]?.id and its an actual discord server ID, so what exactly is the issue? Did I insert the parameter incorrectly?
12 Replies
d.js toolkit
d.js toolkit11mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
SpecialSauce
SpecialSauce11mo ago
What endpoint are you trying to use? I don’t see any params in the actual docs for that route.
Mr. Panda
Mr. Panda11mo ago
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Mr. Panda
Mr. Panda11mo ago
sorry for the ghost ping I sent the wrong URL
Mr. Panda
Mr. Panda11mo ago
Mr. Panda
Mr. Panda11mo ago
SpecialSauce
SpecialSauce11mo ago
Ohh try the options after the userGuilds() 2nd param in get()
Mr. Panda
Mr. Panda11mo ago
so {before: null, after: ...}?
SpecialSauce
SpecialSauce11mo ago
rest.get(routeHere, optionsHere) The route you’re using has no params
Mr. Panda
Mr. Panda11mo ago
not me forgetting how to place params 💀 before I mess something up again, I just wanna clarify the correct format
await rest
.get(Routes.userGuilds(), { after: allBotGuilds[199 * (i + 1)]?.id })
await rest
.get(Routes.userGuilds(), { after: allBotGuilds[199 * (i + 1)]?.id })
SpecialSauce
SpecialSauce11mo ago
Keep in mind I have not used the rest package. But that does look correct.
Mr. Panda
Mr. Panda11mo ago
Yea that did not work ah, so it would look something like this then?
await rest
.get(Routes.userGuilds(), {
query: makeURLSearchParams({
after: allBotGuilds[199 * (i + 1)]?.id,
}),
})
await rest
.get(Routes.userGuilds(), {
query: makeURLSearchParams({
after: allBotGuilds[199 * (i + 1)]?.id,
}),
})
it worksssss! thank you for relieving the pain of me trying to fix this 💀