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

157
Visualizações
My second "if" never works when the conditions are met

When an embed has a footer or not, it sends a message to console.

But the second condition

if (!embed[i] || !embed[i].footer || embed[i].footer.text === null)

does not work.

But if I go down to the condition,

if (embed[i] && embed[i].footer && embed[i].footer.text !== null)

and I go up

if (!embed[i] || !embed[i].footer || embed[i].footer.text === null),

now

if (embed[i] && embed[i].footer && embed[i].footer.text !== null)

does not respond.

The second if doesn't never work

const { Client, Intents } = require("discord.js-selfbot");
const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MESSAGES,
    Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
  ],
});

let token = "";

client.on("ready", () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on("message", (message) => {
    if (message.embeds.length >= 0) {
      // Check if the Message has embed or not
      let embed = message.embeds;
      for (let i = 0; i < embed.length; i++) {
        if (embed[i] && embed[i].footer && embed[i].footer.text !== null)
          return;
        // check each embed if it has footer or not
        {
          console.log("no have footer");
        }
        if (!embed[i] || !embed[i].footer || embed[i].footer.text === null)
          return;
        // check each embed if it has footer or not
        {
          console.log("have footer");
        }
      }
    }
});
client.login(token);
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

you put 2 conditions and if they true you get out with return, but for sure one of them will be true so

{
  console.log("have footer");
}
    

will never be called

about 4 years ago · Juan Pablo Isaza Relatório

0

Code looks off. Maybe try updating to below:

client.on("message", (message) => {
    if (message.embeds.length >= 0) {
      // Check if the Message has embed or not
      let embed = message.embeds;
      for (let i = 0; i < embed.length; i++) {
        // check each embed if it has footer or not
        if (embed[i] && embed[i].footer && embed[i].footer.text !== null)
        {
          console.log("no have footer");
          return;
        }
        // check each embed if it has footer or not
        if (!embed[i] || !embed[i].footer || embed[i].footer.text === null)
        {
          console.log("have footer");
          return;
        }
      }
    }
});

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