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

131
Views
mi matriz deja de funcionar si pongo más de 2 valores

si una inserción tiene uno de los nombres de ListClaims en .setAuthor, reacciona con un emoji, eso es lo que quiero que haga, pero deja de funcionar si pongo más de 1 nombre en ListClaims, intente usar un txt pero no funciona .

 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 answers
Answer question

0

Está llamando a include includes() en una cadena ( author.name ) con un argumento de matriz. Quieres ejecutarlo al revés. Así que en lugar de:

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

Intenta usar:

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

0

la función js include puede hacer referencia aquí

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

la siguiente es la muestra

 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 Report

0

.includes es un método de matriz, pero lo ha usado como un método de cadena.

A continuación, lo arreglé mientras limpiaba su código. El nuevo código está en la función messageHandler.

 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 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!