Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discord.js bot not firing events when a message is sent after update

I used to work on discord bots a while back. However, the message event that I used to handle commands isn't working any more, after an update to discordjs.

I've tried both client.on('message', () => {}) and client.on('interactionCreate', () => {}). However, neither of them seem to fire. Could anybody help?

like image 753
TheLazySquid Avatar asked Oct 17 '25 10:10

TheLazySquid


1 Answers

In discord.js v13 it is now called messageCreate instead of message:

client.on('messageCreate', () => {
   // some code
});

Also, you need to enable all required Intents manually, for example:

const { Client, Intents } = require('discord.js');

const client = new Client({
   intents: [
      Intents.FLAGS.GUILD_MESSAGES,
      Intents.FLAGS.GUILDS
   ]
});
like image 92
Toasty Avatar answered Oct 20 '25 00:10

Toasty



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!