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

135
Vistas
my array stops working if I put more than 2 values

if an insert has one of ListClaims names in .setAuthor it reacts with an emoji, that's what I want it to do, but it stops working if I put more than 1 name in ListClaims, try to use a txt but it doesn't work.

    var ListClaims = ["rick sanchez","alex","juan"];

    if(message.embeds.length >= 0) 
    // Check if the Message has embed or not
    {
      let embed = message.embeds
      // console.log(embed) just a console.log
      for(let i = 0; i < embed.length; i++)
      {
        if(embed[i].author.name === null) return;
        // check each embed if it has setAuthor or not, if it doesnt then do nothing
        {
        if(embed[i].author.name.toLowerCase().includes(ListClaims))
        // check each embed if it includes word
        {
          message.react('🎉')
        }
        }
      }
    }
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You are calling includes() in a string (author.name) with an array argument. You want to run it the other way around. So instead of:

if (embed[i].author.name.toLowerCase().includes(ListClaims))

Try using:

if (ListClaims.includes(embed[i].author.name.toLowerCase()))
about 4 years ago · Juan Pablo Isaza Denunciar

0

the js includes function can reference here

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes

the following is the sample

const array1 = [1, 2, 3];
document.write("Is array1 contain 2 : ");
document.write(array1.includes(2));

document.write("<br>");

document.write("Is array1 contain 4 : ");
document.write(array1.includes(4));

about 4 years ago · Juan Pablo Isaza Denunciar

0

.includes is an array method, but youve used it as a string method.

Below I've fixed it while also cleaning up your code. The new code is in the messageHandler function.

const listClaims = ["rick sanchez", "alex", "juan"];

// dummy message object
const msg = {
  embeds: [
    {name: "alex"},
    {name: null},
    {name: "juan"},
  ],
  react: (str) => console.log(str),
}

function handleMessage(msg){
  if (!msg.embeds.length) return;
  msg.embeds.forEach(embed => {
    if (listClaims.includes(embed.name)) msg.react('🎉');
  })
}

handleMessage(msg)

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