'How do I check if message content includes certain words?

I'm trying to make something like that: when a person writes certain words, the bot responds with a GIF image. Here is my code

const hayday = ('hayday', 'hay day', 'хей дей', 'хейдей', 'хэй дэй', 'хэйдэй')
client.on('message', msg => {
 if (msg.content.toLowerCase().includes(hayday)) {
  msg.channel.send('https://tenor.com/view/hayday-gif-20485973');
}
})

When I send any of options on const hayday bot just ignore me What's wrong? I'm on discord.js 12



Solution 1:[1]

I see 2 issues in your code.

1: Tables do not start and end with (), They start and end with []

2: You are checking if the entire array is found in the message

Try this code.

const hayday = ['hayday', 'hay day', '??? ???', '??????', '??? ???', '??????']
client.on('message', msg => {
 var found = false
 for(const val of hayday){
   if(msg.content.toLowerCase().includes(val)){
      found = true
   }
 }
 setTimeout(() => {
   if(found == true){
     msg.channel.send('https://tenor.com/view/hayday-gif-20485973');
   }
  }, 1000)
})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cmb