bot is online but not resieving messages

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
17 Replies
d.js toolkit
d.js toolkit11mo ago
• 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.
Auto909
Auto90911mo ago
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
Auto909
Auto90911mo ago
Squid
Squid11mo ago
Do you have the MessageContent intent in your client declaration? You also need the GuildMessages intent in the same place
Auto909
Auto90911mo ago
const client = new Discord.Client({ intents: 76864 }); this is my client when i tried to add guildmessages it kept giving me errors
Squid
Squid11mo ago
Magic numbers are meaningless Be more specific than "errors"
Auto909
Auto90911mo ago
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
Squid
Squid11mo ago
that's code for discord.js v13, not v14
d.js docs
d.js docs11mo ago
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
Squid
Squid11mo ago
second bullet point
Auto909
Auto90911mo ago
so correct me if im wrong const { Client, GatewayIntentBits } = require('discord.js'); const client = new Client({ intents: GatewayIntentBits.GuildMessages });
Squid
Squid11mo ago
That's good You now have the GuildMessages intent (to receive basic messages), and you should also add the Guilds (for basic functioning) and the MessageContent (to receive message content) intents
Auto909
Auto90911mo ago
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.....
Squid
Squid11mo ago
My answer does not change
Auto909
Auto90911mo ago
ohh i read it wrong lol
Squid
Squid11mo ago
The intents property can be an array
Auto909
Auto90911mo ago
yes oml i have been trying to figure this out for the past couple of hours thank you so much your a savior