Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

message.content doesn't have any value in Discord.js v14

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

enter image description here

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading