messagecreate 不适用于 discord.js

messagecreate dont working with discord.js

我不知道为什么,但我的代码无法正常工作:

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

使用 discord.js v13 创建 Client with intents 时,格式应如下所示:

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

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

意向格式为 Discord.Intents.FLAGS.<insert the intent here>。您可以找到完整列表 Intent FLAGS.

这包含在 Updating to v13 from v12 discord.js guide