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`)
})
@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;
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!