Alright, so I followed a small tutorial on how to make a discord bot and in the end I got this code:
require('dotenv').config();
const Discord = require("discord.js");
const client = new Discord.Client({intents: ["GUILDS", "GUILD_MESSAGES"]});
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on("message", msg => {
if (msg.content === "ping") {
msg.reply("pong");
}
})
client.login(process.env.DISCORD_TOKEN);
Basically the bot must reply with "Pong" every time someone says "Ping"
After that, the tutorial said that to get the bot online I'd need to run the "node bot.js" command on a terminal, and I did, but the output was clearly an error and not what was shown in the tutorial (also the bot didn't go online)
throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit);
^
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: GUILDS.
at IntentsBitField.resolve (C:\Users\pedro\OneDrive\Ambiente de Trabalho\Nova pasta\node_modules\discord.js\src\util\BitField.js:172:11)
at C:\Users\pedro\OneDrive\Ambiente de Trabalho\Nova pasta\node_modules\discord.js\src\util\BitField.js:167:54
at Array.map (<anonymous>)
at IntentsBitField.resolve (C:\Users\pedro\OneDrive\Ambiente de Trabalho\Nova pasta\node_modules\discord.js\src\util\BitField.js:167:40)
at new BitField (C:\Users\pedro\OneDrive\Ambiente de Trabalho\Nova pasta\node_modules\discord.js\src\util\BitField.js:33:38)
at new IntentsBitField (C:\Users\pedro\OneDrive\Ambiente de Trabalho\Nova pasta\node_modules\discord.js\src\util\IntentsBitField.js:9:1)
at Client._validateOptions (C:\Users\pedro\OneDrive\Ambiente de Trabalho\Nova pasta\node_modules\discord.js\src\client\Client.js:494:25)
at new Client (C:\Users\pedro\OneDrive\Ambiente de Trabalho\Nova pasta\node_modules\discord.js\src\client\Client.js:78:10)
at Object.<anonymous> (C:\Users\pedro\OneDrive\Ambiente de Trabalho\Nova pasta\bot.js:3:16)
at Module._compile (node:internal/modules/cjs/loader:1254:14) {
code: 'BitFieldInvalid'
}
Node.js v18.16.0
I am very confused and I'm sorry if for some this may look like a stupid question and/or mistake, but I just don't know what to do :/
Here is the tutorial link: https://www.xda-developers.com/how-to-create-discord-bot/