【发布时间】:2020-10-09 03:19:25
【问题描述】:
所以在我的代码中,我试图让消息在任何情况下都被接受。例如,真 = TRuE。然而,当我这样做时,我得到了一个我不期望的结果。
而不是给我一个错误,或者做我期望的事情。发送一条消息说“时间到了”。
const safari = function (message) {
message.channel.send(embed).then(() => {
message.channel.awaitMessages(filter, { max: 1, time: 30000, errors: ['time'] })
.then(collected => {
if (collected.first().toLowerCase() == "look at reflection") {
const embed2 = new discord.RichEmbed()
.setTitle("__**Chat to a tourist!**__")
.setColor("#49499c")
.setDescription("You begin to look at yourself, and slowly become infatuated with yourself!\n**__Wait 24 hours before guessing again!__**")
message.channel.send(embed2);
}
else if (collected.first() == "Pond dip") {
const embed2 = new discord.RichEmbed()
.setTitle("__**Off road!**__")
.setColor("#49499c")
.setDescription("You begin to pond dip, you had such a blast!")
message.channel.send(embed2);
}
else if (collected.first() == "Chase a frog") {
const embed2 = new discord.RichEmbed()
.setTitle("__**Trip over a rock!**__")
.setColor("#49499c")
.setDescription("Oh you're very clumbsy luckily its only a bruise!")
message.channel.send(embed2);
}
else { message.channel.send("Could not find this answer"); return safari(message); }
})
.catch(collected => { message.channel.send('Time up'); });
});
如果有人能向我解释为什么会发生这种情况,以及解决问题的可能方法,我会非常感激!
【问题讨论】:
-
您没有在代码的任何地方使用 toLowerCase,只使用 toUpperCase 和小写字符串。
-
对不起,在测试过程中改变了,应该是小写。但问题仍然存在。
标签: javascript node.js discord discord.js