With discord v14, I was trying to use the messageCreate event, however, after a user types a message in discord, message.content doesn't have any data as shown below:
Message {
channelId: '998889338475655188',
guildId: '948995127148425246',
id: '998925735668498433',
createdTimestamp: 1658232854526,
type: 0,
system: false,
content: '',
author: User
I have tried searching around and can't find any solution to the issue, the code I am using relating to discord is:
import { Client, GatewayIntentBits, Partials } from "discord.js";
const bot = new Client({
'intents': [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildMessages
],
'partials': [Partials.Channel]
});
bot.on('messageCreate', async (message) => {
console.log(message);
});
bot.login(process.env.token1)
Does anyone have any idea what is wrong or what needs changing from the new update?
Make sure you enable the message content intent on your developer portal and add the GatewayIntentBits.MessageContent enum to your intents array.
Applications ↦ Settings ↦ Bot ↦ Privileged Gateway Intents

You'll also need to add the MessageContent intent:
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],
});
And make sure to use the messageCreate event instead of message:
client.on('messageCreate', (message) => {});
If you're using discord.js v13, you'll need to enable the message content intent on your developer portal and if your bot uses the Discord API v10, you will need to add the MESSAGE_CONTENT flag to your intents:
const { Client, Intents } = require('discord.js');
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.MESSAGE_CONTENT,
],
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With