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

247
Vistas
discord.js respond to specific words in sentence

So I'm trying to add a help detector to my discord bot which auto responds to certain stuff. For example if someone types I want help with login it should auto respond, but if someone says I want help it should do nothing, so it only responds if it detects that the sentence contain help and login and I've tried to make a code for this but it doesn't respond at all, here is the code:

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)
}

I've also tried to use .indexOf() instead of .includes() but when I used that it responded to every message that was typed which is not what I want. I don't get any errors either or anything in the console. So question is, how would I make the discord bot respond to specific words in sentance

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are trying to check with the whole array. The function automatically converts it to a string, meaning you are actually doing this:

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

What I think you want is to check if the message includes anything from the array. You can do this using 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 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