Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

392
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!