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
griffOP6mo ago
No description
vince
vince6mo 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
griffOP6mo ago
thanks bae
MarkBoots
MarkBoots6mo 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
griffOP6mo ago
you're bae now
Want results from more Discord servers?
Add your server