TheLazySquid
TheLazySquid

Reputation: 89

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?

Upvotes: 4

Views: 5330

Answers (1)

Toasty
Toasty

Reputation: 1880

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
   ]
});

Upvotes: 10

Related Questions