simple discord.js bot question

hey, I have a bot for my NFL server and I wrote this script to ping a user who hates the player Trevor Lawrence anytime tlaw is mentioned. It will read a message for tlaw and ping the user, but for whatever reason capitalized t in Tlaw does not work -- I thought using the | | operator would work but it isn't, thoughts?
No description
5 Replies
griff
griff2mo ago
No description
vince
vince2mo ago
lol, I don't think you can do an || in .includes() There's more compact ways, but it should work if you list it out individually, eg: message.content.includes('tlaw') || message.content.includes('Tlaw') More compact ways I can think of are having an array of bannable words and checking if it's in the array, or some regex .match() I'd have to look into the compact ways though
griff
griff2mo ago
thanks bae
MarkBoots
MarkBoots2mo ago
or with one regex, case insensitive
if(/tlaw/gi.test(message.content)){
...
}
if(/tlaw/gi.test(message.content)){
...
}
and with a list, maybe this
const badMessageReplies = [
{ bad: "tlaw", reply: "<@12346789>" },
{ bad: "something else", reply: "alrighty then" },
];

const badMessage = badMessageReplies.find(({bad}) => message.content.toLowerCase().includes(bad));
if(badMessage) message.reply(badMessage.reply)
const badMessageReplies = [
{ bad: "tlaw", reply: "<@12346789>" },
{ bad: "something else", reply: "alrighty then" },
];

const badMessage = badMessageReplies.find(({bad}) => message.content.toLowerCase().includes(bad));
if(badMessage) message.reply(badMessage.reply)
griff
griff2mo ago
you're bae now