Home > OS >  messagecreate dont working with discord.js
messagecreate dont working with discord.js

Time:05-31

i don't know why but my code dont work without any error:

    const Discord = require("discord.js");
const client = new Discord.Client({ intents: [ 'DIRECT_MESSAGES', 'GUILD_MESSAGES' ] });

client.on("ready", () => {
    console.log("ready");
});

client.on("messageCreate", (message) => {
    if (message.content.endsWith("quoi")) {
        message.channel.send("feur");
    };

    console.log("message");
});

CodePudding user response:

When using discord.js v13 creating a Client with intents should be formatted like this:

const Discord = require('discord.js');

const client = new Discord.Client({
  intents: [
    Discord.Intents.FLAGS.DIRECT_MESSAGES,
    Discord.Intents.FLAGS.GUILD_MESSAGES,
  ],
});

The intents format is Discord.Intents.FLAGS.<insert the intent here>. You can find a full list Intent FLAGS.

This is included in the Updating to v13 from v12 discord.js guide

  • Related