Need help with a complex command that detects phrases

Hi. I’m trying to create a command that makes nightbot reply to phrases in chat. the purpose of the command is to reply to users who ask the streamer if he or she can play with them. I found a basic way to do this command here:
!commands edit can $(eval var a = "$(query)"; if (a === "I play?") { ("$(user) Please do not ask Lexi to play. If you are on the stream often and give off chill vibes, Lexi might invite you to play if there's room in the squad ❤️"); } else { (" "); })

However the problem is with this, the command cannot detect variations of the phrase “can” followed by “I play” or “i play” or “i play?” (different capitalizations and with or without a question mark). How can I edit the aforementioned command to include more “detection phrases?” I appreciate any and all help. thanks!

1 Like

Case-insensitive search for if query has “I play”. Basically turn the whole query string lower/uppercase and use includes() method:

!commands edit can $(eval decodeURIComponent("$(querystring)").toLowerCase().includes("i play")?"$(user) Please do not ask Lexi to play. If you are on the stream often and give off chill vibes, Lexi might invite you to play if there's room in the squad ❤️":" ")

this is amazing. thank you so much :slight_smile:

1 Like

is it possible to detect “can I join?” as well?

1 Like

Sure, just create an OR conditional:

!commands edit can $(eval a=decodeURIComponent("$(querystring)").toLowerCase();a.includes("i play")||a.includes("i join")?"$(user) Please do not ask Lexi to play. If you are on the stream often and give off chill vibes, Lexi might invite you to play if there's room in the squad ❤️":" ")

thank you very much for your help

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.