How to exclude users/userlevels from calling a command

I have a command that responds “no” when someone types “can” in chat to discourage new chatters who ask to play with me. When regulars want to ask a question starting with “can” they get the no response too.

Command: can
Message: no $(user)

I want to exclude mods, vips and subscribers from this command. If it isn’t possible to set a maximum userlevel, is there is a way to filter out certain users I could set it to ignore 10-15 regulars in chat.

Thanks :slight_smile:

Hey @katf9!

You can do so using the $(userlevel) variable, please read the documentation.

So if you want your command to answer “no” to everyone who asks “can I play with you,” except specific userlevel, you can do it like so:

!addcom can $(eval ['subscriber', 'twitch_vip', 'moderator'].includes('$(userlevel)') ? ' ' : '$(query)'.toLowerCase().includes('i play') ? 'no $(user)' : ' ';)

Hi Emily, thank you for the reply!

I added the command and tested it from an unsubscribed account and there is no response at all from nightbot. I tested an unsubscribed account saying “can” “can i” “can i play” “i play” and all had no response.

If they start a message with “can” i want nightbot to reply to them and say “no”.

Any further help would be appreciated :slight_smile:

Ah, I wasn’t sure you wanted a “no” answer for every messages starting with “can,” I assumed otherwise because of the explanation you gave.

“Can I play(?)” should have worked tho’, I checked it, so if not, you did something wrong.

Anyway, here’s how you have it answer for every message starting with “can:”

!addcom can $(eval ['subscriber', 'twitch_vip', 'moderator'].includes('$(userlevel)') ? ' ' : 'no $(user)';)

that works perfectly, thank you