'message.content.includes doesn't works (?)

const banWord = ["meat","fruit","road"];
    for (var i = 0; i < banWord.length; i++) {
        if(message.content.includes(banWord[i])) {
            message.channel.send('🙏🏻🙏🏻Mohon yang sopan ya...😊😊');
        }
      }

the bot won't say anything at discord server when someone says that words.



Solution 1:[1]

I cannot remember the exact thing, but here is something off my memory. Instead of message.content.includes(), you might be able to use message.content.has(). Again, I am not sure, nor I can try right now. So, sorry in advance if it doesn't work

Solution 2:[2]

You need to put that script inside of a client function. For example:

client.on('message', message => {
    for (var i = 0; i < banWord.length; i++){
        if(message.content.includes(banWord[i])) {
            message.channel.send('????Mohon yang sopan ya...??')
        }
    }
})

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 FanBoy9344
Solution 2 Mime