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

391
Vistas
why is message.channel.awaitMessages() not working? | Discord.js V13

I'm trying to collect a message after a certain message a user has sent in a specific channel. So the user would send say hello world then await messages would wait for a response from a specific user and grab that message's ID. However, it doesn't work.

Here is my code:

let filter = message => {
    return message.author.id == 'ID OF USER';
}

if(message.channel.id == 'channel id of sent message') {
            console.log('here');
            if(message.content.valueOf("hello world")) {
                console.log('here');
                message.channel.awaitMessages(bumpFilter, { max: 1, time: 5000, errors: ['time']})
                .then(c => {
                    console.log('here');
                    console.log(c);
                });
            }
        }

In the console, here is logged 2 times. However, the 3rd time is not logged, even after the 5 seconds has passed from this message. The console logs nothing, not even an error, which got me to speculate that maybe it's an discord intents issue, but i don't think that was it either. So i don't understand what's the issue and why I won't get any results. Also, if i assigned message.channel.awaitMessages(...) to a var then logged the var it would output Promise { <pending> } and I read that a .then statement has to be added to avoid that. And now that it is added, it still does not output anything.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

First, if (message.content.valueOf("hello world")) will always return true as the valueOf method returns the primitive value of the specified object. Even if message.content is not "hello world", it's still truthy. You should check if the value of message.content itself is equal to "hello world".

Second, you declare a filter variable but you use bumpFilter in your awaitMessages

And third, in discord.js v13, awaitMessages accepts a single parameter, an options object. (In v12 the first parameter was a filter and the second one is the options).

let filter = (message) => {
  return message.author.id === 'ID OF USER';
};

if (message.channel.id === 'channel id of sent message') {
  console.log('channel matches');

  if (message.content === 'hello world') {
    console.log('message is hello world');

    message.channel
      .awaitMessages({ filter, max: 1, time: 5000, errors: ['time'] })
      .then((c) => {
        console.log('New message collected');
        console.log(c);
      })
      .catch((c) =>
        console.log(`After five seconds, ${c.size} messages are collected.`),
      );
  }
}
about 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