If/Else based on user input

Is there a (resonable) way to get Nightbot to respond (without writing an external JS) to do one action IF there is input and another if not? For example: !cookie $(user) gave $(touser) a cookie IF there is input, otherwise call the 2g.be randomviewer return? So, if I type !cookie USERNAME it returns “ToeKneeTM gave USERNAME a cookie” but if I JUST type !cookie, I can fetch a random viewer using the 2g.be randomviewer call and return “ToeKneeTM gave RANDOMVIEWER a cookie”? Thank you in advance!

Try this

!addcom -cd=5 !cookie $(user) gave $(eval a=decodeURIComponent(`$(querystring)`);b=`$(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))`;a?a.slice(0,400):(b!=`Empty viewer list`?b:`no one`)) a cookie

You. Are. Awesome. Can I share this? How can I give you credit? Social, Stream or Youtube link? I’m the same name pretty much everywhere.

Feel free to share this code! And there’s no need at all to credit me, though at the most you can perhaps give me a little shoutout if anyone asks where you got the code.

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