#Discord bot

7 messages · Page 1 of 1 (latest)

wanton aspen
#

Trying to code this bot but it always give me errors and I am new to javascript so I have no idea what I'm doing wrong

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.GUILDS, GatewayIntentBits.GUILD_MESSAGES] });

client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});

client.on('messageCreate', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!');
}
});

client.login('token');

chrome narwhal
#

What errors

wanton aspen
#

C:\Users\Danie\Desktop\DiscordBot\node_modules\discord.js\src\util\BitField.js:170
throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit);
^

RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at IntentsBitField.resolve (C:\Users\Danie\Desktop\DiscordBot\node_modules\discord.js\src\util\BitField.js:170:11)
at C:\Users\Danie\Desktop\DiscordBot\node_modules\discord.js\src\util\BitField.js:165:54
at Array.map (<anonymous>)
at IntentsBitField.resolve (C:\Users\Danie\Desktop\DiscordBot\node_modules\discord.js\src\util\BitField.js:165:40)
at new BitField (C:\Users\Danie\Desktop\DiscordBot\node_modules\discord.js\src\util\BitField.js:33:38)
at new IntentsBitField (C:\Users\Danie\Desktop\DiscordBot\node_modules\discord.js\src\util\IntentsBitField.js:9:1)
at Client._validateOptions (C:\Users\Danie\Desktop\DiscordBot\node_modules\discord.js\src\client\Client.js:491:25)
at new Client (C:\Users\Danie\Desktop\DiscordBot\node_modules\discord.js\src\client\Client.js:78:10)
at Object.<anonymous> (C:\Users\Danie\Desktop\DiscordBot\main.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1275:14) {
code: 'BitFieldInvalid'
}

Node.js v19.9.0

chrome narwhal
#

Notice none of them are capitalized

#

I think that's your issue

wanton aspen
#

Thanks!! It worked