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

197
Visualizações
solo funciona si el contenido de author.name es exacto o sobran palabras

El bot reacciona solo cuando el contenido de author.name es exacto, pero si tiene una palabra extra no funciona, pero no arroja un ejemplo de error:

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

rick sanchez no tiene error porque es exacto a ListClaims

rick sanchez morty tiene un error porque tiene letras adicionales que es morty ,

 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] || !embed[i].author || 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
1 Respostas
Responde à pergunta

0

He reformateado su código, por lo que es más simple y fácil de leer. Si da un mejor ejemplo de lo que quiere que suceda, puedo editar esta respuesta para resolverlo mejor.

 function messageHandler() { const msg = { embeds: [ { author: { name: "alex" }}, { author: { name: "john"}}, { author: { name: "rick sanchez morty"}}, ] } const listClaims = ["rick sanchez", "alex", "juan"]; // 0 is falsey by default, so you dont have to check if it's == 0. if (!msg.embeds.length) return; // Check if the Message has embed or not msg.embeds.forEach(embed => { // "", null and undefined are also falsey, so we don't need to check them. // also this if statement is not needed, since you can just do Array.includes(). if (!embed.author.name) return; // .includes() is an array method, not a string method, so you have to do Array.includes(target), not target.includes(array). if (listClaims.includes(embed.author.name.toLowerCase())) message.react('🎉'); }); } const message = { react: console.log }; messageHandler()

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