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

241
Views
discord.js responde a palabras específicas en la oración

Así que estoy tratando de agregar un detector de ayuda a mi bot de discordia que responde automáticamente a ciertas cosas. Por ejemplo, si alguien escribe I want help with login , debería responder automáticamente, pero si alguien dice I want help , no debería hacer nada, por lo que solo responde si detecta que la oración contiene ayuda e inicio de sesión y he intentado hacer un código. para esto pero no responde en absoluto, aquí está el código:

 let help_words2 = ["help", "problems", "problem", "error", "issue"] let help_words = ["psutil", "pyinstaller"] if (message.content.toLowerCase().includes(help_words) && message.content.toLowerCase().includes(help_words2)) { const embed = new MessageEmbed() .setAuthor(`I'm here to help ${message.author.tag}!`,'https://img.icons8.com/fluency/48/000000/help.png',`${client.config.links.website}`) .setDescription(`**I think you need help with python and before asking more questions make sure to check out these pages/channels**\n\n> <#905804981368664075>\n> <#905224439736705087>`) message.channel.send(embed) }

También traté de usar .indexOf() en lugar de .includes() pero cuando lo usé respondió a cada mensaje que se escribió, que no es lo que quiero. Tampoco me sale ningún error ni nada en la consola. Entonces, la pregunta es, ¿cómo haría que el bot de Discord respondiera a palabras específicas en una oración?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Está tratando de verificar con toda la matriz. La función lo convierte automáticamente en una cadena, lo que significa que en realidad estás haciendo esto:

 message.content.toLowerCase().includes("psutil,pyinstaller")

Lo que creo que quieres es verificar si el mensaje incluye algo de la matriz. Puedes hacer esto usando Array.prototype.some :

 if (help_words.some(w => message.content.toLowerCase().includes(w)) && help_words2.some(w => message.content.toLowerCase().includes(w))) { //rest of your code }
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!