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

96
Views
awaitMessages filter doesn't run .then?

I'm running a dm prompt from my bot, where the player needs to reply before the bot continues asking. I set up a filter so that the bot doesn't detect and count its own message, but it doesn't seem to be triggering the ".then()" function.

My code:

            let filter = m => m.author.id != client.user.id
            channel.awaitMessages(filter, {max: 1, time: 1000*180, errors: ['time']})
                .then(msg => {
                    console.log("got to the then")
                    let replymsgobject = msg.first()
                    let reply = replymsgobject.content
                    let checkstringarr = [
                        "payment",
                        "about",
                        "team",
                        "requirements"
                    ]
                    if (contains("or", reply, checkstringarr)) {
                        channel.send(`Your post doesn't follow the format.`)
                    } else {
                        channel.send(`succesfully set your post message, would you like to add any extra comments?`)
                        let filter = m => m.author.id != client.user.id
                        channel.awaitMessages(filter, {max: 1, time: 1000*120, errors: ['time']})
                            .then(replymsg => {
                                if (contains("only", replymsg.content, "no")) {
                                    //some stuff
                                } else {
                                    //some stuff
                                }
                            })
                            .catch(collectedcatchmsg => {
                                channel.send(`timed out`)
                            })
                    }
                })
                .catch(collectedcatchmsg => {
                    channel.send(`timed out`)
                })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

@Toasty said (sorry Toasty), "it will wait until the timer is over". This is incorrect, it will give you the promise once for example the max messages have been reached.

why would it wait for 3 mins if it gets the required answer in 10secs??

Now I'm a little lost do you want the command executor to reply to that message collector or do you not? Because right now your filter is not accepting any messages sent by the command executor/message sender.

To fix this just edit your filter

const filter = m => m.author.id === message.author.id;

if you want someone else's message to be collected and not the message authors, then you would do

const filter = m => m.author.id !== message.author.id;
about 4 years ago · Juan Pablo Isaza Report

0

Turns out there were 2 errors! First off the filter dictionary was supposed to be inside the table with the requirements, etc., The second error was using != instead of !==, Thanks to @Patrik for helping out here!

about 4 years ago · Juan Pablo Isaza 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!