I'm trying to figure out how to get a specific word from an entire message. Like using a profanity filter.
for (let x = 0; x < profanities.length; x++) {
if (message.content.toUpperCase().includes(profanities[x].toUpperCase())) {
message.channel.send('Oooooooh you said a bad word!');
client.channels.get('484375912389935126').send(`Message was deleted due to use of a blocked word:\n\n"${message.content}"`);
message.delete();
return;
}
}
Now this works except for the fact that if a word was said inside another word it finds it too because of the .includes like if I were to block "bum" and someone says "bumble" it would delete "bumble" as well. That's all well and good for profanity filters but I wanted to do a fun one for a member:
const words = message.content.toLowerCase();
if (words.includes('bum')) {
setTimeout(function() {
message.channel.send('Are we talking about <@memberID>?!');
}, 1500);
}
I used "memberID" instead of the real ID. But this finds "bum" in "bumble" but I only want it to find "bum" as a separate word within the message. Like "This bum is weird" or something like that.