Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda