Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
Discord.js V14 - client.on message create not firing

I'm trying out V14 of Discord.js, and there are so many new things! But this whole intents thing, I'm not getting for some reason. My messageCreate is not firing, and from other posts, I believe it has something to do with intents. I've messed around with intents, but nothing seems to work. Here is my code:

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});
client.on("messageCreate", (message) => {
  console.log("new message...")
  console.log(message.message)
  console.log(message.content)
if (message.mentions.users.first() === client) {
  message.reply("Hey!.")
} 
});
client.login(process.env.token);

Thanks!!

almost 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Figured it out! You need to turn on message content intents in the developer portal:

Picture

Also, you need to have messageContent intent at the top:

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [ 
  GatewayIntentBits.DirectMessages,
  GatewayIntentBits.Guilds,
  GatewayIntentBits.GuildBans,
  GatewayIntentBits.GuildMessages,
  GatewayIntentBits.MessageContent,] });
client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});
client.on("messageCreate", (message) => {
if (message.content === "<@1023320497469005938>") {
  message.reply("Hey!")
} 
});
client.login(process.env.token);

As for getting the ping from the message, not my initial question but something I needed to fix, just use if (message.content) === "<@BotID>" {CODE HERE}

almost 4 years ago · Santiago Trujillo Denunciar

0

You need the GuildMessages intent.

Note: You do not need the MessageContent intent in messages that ping the bot, as bots can receive content from messages that ping them without the intent.

const client = new Client({ 
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages
  ]
});
// ...
client.on("messageCreate", (message) => {
  // ...
  if (message.mentions.users.has(client.user.id)) { // this could be modified to make it have to *start* with or have only a ping
    message.reply("Hey!.")
  } 
});
// ...
almost 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda