Rest returns 404 error

This might be because I'm doing something wrong, but when I try to use the rest api option I get a 404 error (this happens with every route). However if I use fetch I get back the actual result. I'm setting a token (I assume setToken sets the token on the Authorization header, other wise I would get an 401 error instead).
import { REST, Routes } from "discord.js"

const rest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN);

try {
const result = await rest.get(Routes.guildRoles(<Insert Guild Id>)); <-- returns a 404 error.

const result2 = await fetch(Routes.guildRoles(<Insert Guild Id>), {
method: "get",
headers: {
Authorization: `Bot ${process.env.DISCORD_TOKEN}`
}
}) <-- this works and returns the roles for the guild.
catch (err: any) {
/** DO STUFF
}
import { REST, Routes } from "discord.js"

const rest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN);

try {
const result = await rest.get(Routes.guildRoles(<Insert Guild Id>)); <-- returns a 404 error.

const result2 = await fetch(Routes.guildRoles(<Insert Guild Id>), {
method: "get",
headers: {
Authorization: `Bot ${process.env.DISCORD_TOKEN}`
}
}) <-- this works and returns the roles for the guild.
catch (err: any) {
/** DO STUFF
}
1 Reply
d.js toolkit
d.js toolkit12mo ago
- 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!