0

I have the following code. The discord.js version is 13.x. The problem is that the message.content is "" (empty) while it should be a text content. An year ago the same script was working fine so this is very weird.

const fs = require('fs');
const yaml = require('js-yaml');
const moment = require('moment');

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

let config = yaml.load(fs.readFileSync("./config.yml", 'utf8'));

client.on("message", (message) => {
  console.log(message.content) // "" (empty), why??
});

client.login(config.discord.token);

Versions:

$ node -v
v16.6.0

"discord.js": "^13.3.1",
  • As I mentioned in my linked answer, you'll need to add `Intents.FLAGS.MESSAGE_CONTENT` and enable the message content intent on your developer portal. – Zsolt Meszaros Jun 19 '23 at 10:37

0 Answers0