79532420

Date: 2025-03-25 00:16:25
Score: 1
Natty:
Report link

Use the JavaScript .toLowerCase() function to convert everything in the message to lower-case and .includes() to check for the matching string in the message when comparing the message to your desired text (read more toLowerCase and includes):

// the time of the last help message
let lastHelpTime = 0

client.on('message', (channel, tags, message, self) => {
    const send = message.toLowerCase().includes("!help")

    if (!send ) return;

    // get the current time
    const timeNow = new Date().getTime()
    // check if at least 1 minute has elapsed since the last help message
    if (timeNow - lastHelpTime > 60 * 1000) {
        // update the last help message time
        lastHelpTime = timeNow
        // post the help message in chat
        client.say(channel, `This is the help message`)
    }

    console.log(`${tags['display-name']}: ${message}`);
});

Example

console.log("!HELP".toLowerCase().includes("!help"))
console.log("!HeLp".toLowerCase().includes("!help"))
console.log("!help".toLowerCase().includes("!help"))
console.log("!hElp mE Bot".toLowerCase().includes("!help"))

Reasons:
  • Blacklisted phrase (1): help me
  • Blacklisted phrase (1): hElp mE
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Jacques Rossouw