Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda