Home >Web Front-end >JS Tutorial >Why is `message.content` Empty in Discord.js v14 (and how to fix it)?
How to Resolve Discord.js's "message.content doesn't have any value" Error
In the latest version (v14) of Discord.js, the message.content property may return an empty string despite receiving messages from users. This issue arises due to the removal of the default Message Content Intent.
Solution for Discord.js v14
To resolve this issue, you need to:
const { Client, GatewayIntentBits, Partials } = require('discord.js'); const client = new Client({ intents: [ GatewayIntentBits.DirectMessages, GatewayIntentBits.Guilds, GatewayIntentBits.GuildBans, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, ], partials: [Partials.Channel] });
client.on('messageCreate', (message) => {});
Solution for Discord.js v13
For Discord.js v13, the solution is similar:
const { Client, Intents } = require('discord.js'); const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.MESSAGE_CONTENT, ], });
The above is the detailed content of Why is `message.content` Empty in Discord.js v14 (and how to fix it)?. For more information, please follow other related articles on the PHP Chinese website!