#bot is online but not resieving messages

22 messages · Page 1 of 1 (latest)

slim palm
#

Hello i am new to coding and i got my bot to go online but when i send a command in the discord it doesnt show up in the console or respond please help

muted flameBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

slim palm
#

my discord.js is 14.11.0 and my node -v is v18.16.1

#

there no error message or anything this is all that happens

fallen cloak
#

You also need the GuildMessages intent in the same place

slim palm
#

const client = new Discord.Client({
intents: 76864
});

#

this is my client when i tried to add guildmessages it kept giving me errors

fallen cloak
#

Magic numbers are meaningless
Be more specific than "errors"

slim palm
#

this was there error
as i said i am new to coding
C:\Users\Lavis\Desktop\myBot>node bot.js
C:\Users\Lavis\Desktop\myBot\node_modules\discord.js\src\util\BitField.js:172
throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit);
^

RangeError [BitFieldInvalid]: Invalid bitfield flag or number: GUILDS.
at IntentsBitField.resolve (C:\Users\Lavis\Desktop\myBot\node_modules\discord.js\src\util\BitField.js:172:11)
at C:\Users\Lavis\Desktop\myBot\node_modules\discord.js\src\util\BitField.js:167:54
at Array.map (<anonymous>)
at IntentsBitField.resolve (C:\Users\Lavis\Desktop\myBot\node_modules\discord.js\src\util\BitField.js:167:40)
at new BitField (C:\Users\Lavis\Desktop\myBot\node_modules\discord.js\src\util\BitField.js:33:38)
at new IntentsBitField (C:\Users\Lavis\Desktop\myBot\node_modules\discord.js\src\util\IntentsBitField.js:9:1)
at Client._validateOptions (C:\Users\Lavis\Desktop\myBot\node_modules\discord.js\src\client\Client.js:494:25)
at new Client (C:\Users\Lavis\Desktop\myBot\node_modules\discord.js\src\client\Client.js:78:10)
at Object.<anonymous> (C:\Users\Lavis\Desktop\myBot\bot.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1256:14) {
code: 'BitFieldInvalid'
}

Node.js v18.16.1

#

what i used for this was
const client = new Discord.Client({
intents: [
'GUILDS',
'GUILD_MESSAGES',
'GUILD_MESSAGE_REACTIONS'
]
});

#

I then changed it to what i have now and it worked

fallen cloak
grizzled ridgeBOT
#

RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined

  • All SCREAMING_SNAKE_CASE enums have been changed to PascalCase
  • Intents: Intents.FLAGS.GUILD_MESSAGES -> GatewayIntentBits.GuildMessages
  • Permissions: Permissions.FLAGS.SEND_MESSAGES -> PermissionFlagsBits.SendMessages
fallen cloak
#

second bullet point

slim palm
#

so correct me if im wrong
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: GatewayIntentBits.GuildMessages
});

fallen cloak
slim palm
#

this is what i have
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: GatewayIntentBits.GuildMessages
});

let todoList = {};
let staffList = {
auto909: true
};

client.on('ready', () => {
console.log(Bot is ready as: ${client.user.tag});
});

client.on('messageCreate', message => {
console.log(Message received: ${message.content});

if (message.author.bot) return;
const args = message.content.trim().split(/ +/g);
const command = args[0].toLowerCase();

switch (command) {
case '/add':
const item = args.slice(1).join(' ');
if (!todoList[message.guild.id]) todoList[message.guild.id] = {};
todoList[message.guild.id][item] = { stage: 'Not Started', assignee: 'None' };
message.channel.send(Added item: ${item});
break;
yada yada yada.....

fallen cloak
#

My answer does not change

slim palm
#

ohh i read it wrong lol

fallen cloak
#

The intents property can be an array