Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Number check failing/getting ignored. Discord.js

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try replacing the second condition with this, it checks if the number is below zero or above 4

if ( num < 0 || num > 4 )
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading