数字检查失败/被忽略。 discord.js
我正在尝试制造一个允许最多3次打击的罢工系统,因此,当我尝试检查StrikeNumber
是否在1到3之间时,它会忽略,如果
声明,我不确定为什么,但是我已经尝试了多种修复方法,但似乎仍然失败。
这是被忽略的语句,这是:
let strikeNumber = args[2] //(Args 0 is the command it self, Args 1 is the user, Args 2 is the `Strikenumber`, and Args 3 is the reason.)
if (!strikeNumber) {
return message.reply("Please state the number of the strike. (Example: 1, 2, 3)")
} if (!strikeNumber > 0 && !strikeNumber < 4) {
return message.reply("Strike number must be from 1 to 3.")
}
并非所有代码都在这里,并且没有错误,它只是忽略语句。
I'm trying to make a strike system that allows up to 3 strikes, so, when I try to check if the strikeNumber
is between 1 and 3, it ignores the if
statement, I'm not sure why, but I've tried multiple ways to fix it, and it still seems to fail.
Here is the if
statement that is getting ignored:
let strikeNumber = args[2] //(Args 0 is the command it self, Args 1 is the user, Args 2 is the `Strikenumber`, and Args 3 is the reason.)
if (!strikeNumber) {
return message.reply("Please state the number of the strike. (Example: 1, 2, 3)")
} if (!strikeNumber > 0 && !strikeNumber < 4) {
return message.reply("Strike number must be from 1 to 3.")
}
Not all the code is here, and there is no error, it just ignores the if
statement.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试用此替换第二个条件,它检查数字是否低于零
或
4Try replacing the second condition with this, it checks if the number is below zero
or
above 4您是否使用2个语句而不是其他情况?这会实现您的目标吗?
Is there a reason you are using 2 if statements instead of an if else? Does this accomplish your goal?