0
bot.on('message', msg=>{
   if(msg.content.includes(“hi” or? “hello” or? “hey”)){
      msg.reply(“hi” or? “hello” or? “hey”);
   }
})

I’m coding a discord bot on my server and I want to add a feature where it responds to people. I want to make it so that my bot can detect multiple ways a user greets and have it greet them back.

3 Answers3

1
const greetings = ['hi', 'hello', 'hey'];

if (greetings.includes(msg.content)) {...}
Nikita Madeev
  • 4,284
  • 9
  • 20
0
const greetings = {
"hi": "hi",
"hello":"hello"
.....
}

if (greetings[msg.content]) {}
Zain Ul Abideen
  • 1,617
  • 1
  • 11
  • 25
0

How to check if a string contains text from an array of substrings in JavaScript?

if (substrings.some(v => str.includes(v))) {
    // There's at least one
}