Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
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.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

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

if ( num < 0 || num > 4 )
about 4 years ago · Juan Pablo Isaza Report

0

Is there a reason you are using 2 if statements instead of an if else? Does this accomplish your goal?

if (!strikeNumber) {
    return message.reply("Please state the number of the strike. (Example: 1, 2, 3)")
} else {

    if (x === 1 || x === 2 || x === 3) {
        return message.reply("Strike number is 1, 2 or 3")
    } else {
        return message.reply("Strike number must be from 1 to 3.")
    }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!