I tried the 2 solutions posted here to detect a specific words and they do work:
Solution 1
const badMessages = ["bad", "worst"];
badMessages.forEach((word) => {
if (message.content.includes(word)) {
message.reply("Detected.");
}
})
Solution 2
const badMessages = ["bad", "worst"];
for(var i=0; i<badMessages.length; i++) {
if (message.content.includes(badMessages[i])) {
message.reply("Detected.");
}
}
However, the condition triggers even when the word in the array for example bad is mixed with other words like "badge". How do I detect a specific word by itself which should trigger for the exact "bad" word only and not trigger when it is mixed with other words like badge.