Trying to create a custom command that mentions users and fails when no user is specified

I’m trying to create a custom command for nightbot that thanks a user for subscribing and asks them to choose a color. Currently, I’m using the [touser] variable to mention the user by typing “!color .” This returns “Thanks for subbing, ! Choose a color…” So by using [touser], if there is not an argument after the command, it uses the name of who sent the command.

Is there a way I can make the command fail if there is no user mentioned after !color ? The streamer I mod for sometimes forgets to mention the user after the command so it ends up printing “Thanks for subbing, <streamer’s name>!” Thanks for any help!

!commands add !color $(eval user = decodeURIComponent(`$(querystring)`); user ? `Thanks for subbing, ${user}! Choose a color…` : "No user specified")

Change "No user specified" to " " if you don’t want any error message.

1 Like

this works flawlessly. thank you very much!

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