Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda