Had another post about my bot running in the terminal, but not posting a message in the discord channel. I changed the intents because I cam across a different question where someone needed to change the intents so that the bot would post in Discord.. After I made the change to intents I am now getting this error: RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: undefined.
require('dotenv').config();
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILD_MESSAGES, Intents.message, Intents.channel, Intents.reaction] });
client.on('ready', () => {
console.log(`It's welcome time`);
});
client.on('message', msg => {
if (msg.content === 'Hi') {
msg.reply('Welcome wallet warrior!');
msg.channel.send('Welcome wallet warrior!');
}
else {
msg.channel.send('Hi, please introduce yourself')
};
});
client.login(TOKEN);
It's because Intents.message Intents.channel Intents.reaction is undefined, or has no value.
The right Intents you probably need:
const { Client, Intents } = require('discord.js');
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
]
});
There is a discord.js official guide that might help you. Intents Calculator