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

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

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

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 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