Home > Back-end >  message.content doesn't have any value in Discord.js v14
message.content doesn't have any value in Discord.js v14

Time:07-19

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?

CodePudding user response:

Make sure you enable the message content intent on your enter image description here

const client = new Client({
  intents: [
    GatewayIntentBits.DirectMessages,
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildBans,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
  ],
  partials: [Partials.Channel],
});
  • Related