awaitMessages filter 不运行 .then?



我正在运行来自我的bot的dm提示,玩家需要在bot继续询问之前回复。我设置了一个过滤器,使机器人不检测和计数自己的消息,但它似乎没有触发" then()"函数。

我代码:

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表示(对不起Toasty),"它将等待计时器结束"。不正确,例如,一旦达到最大消息数,它将给您承诺。

如果它在10秒内得到所需的答案,为什么要等3分钟?

现在我有点困惑了你想让命令执行器回复消息收集器还是不回复?因为现在您的过滤器不接受命令执行器/消息发送器发送的任何消息。

要解决这个问题,只需编辑你的滤镜
const filter = m => m.author.id === message.author.id;

如果您希望收集其他人的消息而不是消息作者的消息,那么您将执行

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

原来有两个错误!首先,过滤器字典应该是在表内的需求等,第二个错误是使用!=而不是!==,感谢@Patrik在这里的帮助!

最新更新