require("dotenv").config();
const { Client, Intents } = require("discord.js");
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
client.on("ready", () => {
console.log("bot is ready");
});
client.login(process.env.DISCORD_BOT_TOKEN).catch((e) => {
console.log(e);
});
OUTPUT
HTTPError [ReferenceError]: AbortController is not defined
at RequestHandler.execute (g:\goofy-translator\node_modules\discord.js\src\rest\RequestHandler.js:172:15)
at RequestHandler.execute (g:\goofy-translator\node_modules\discord.js\src\rest\RequestHandler.js:176:19)
at RequestHandler.push (g:\goofy-translator\node_modules\discord.js\src\rest\RequestHandler.js:50:25)
at async WebSocketManager.connect (g:\goofy-translator\node_modules\discord.js\src\client\websocket\WebSocketManager.js:128:9)
at async Client.login (g:\goofy-translator\node_modules\discord.js\src\client\Client.js:245:7) {
code: 500,
method: 'get',
path: '/gateway/bot',
requestData: { json: undefined, files: [] }
}
The error is caused by client.login() method.Already triple checked the bot token and all seems fine. The problem isn't in the enviroment varible either, because also doesn't work when I pass the token directly.
[Resolved] The problem was the node version, discord.js requires v16 min