Need help with slap command

I’m trying to make a slap command that will slap a user with a random item. I have tried using the $rand command and it doesn’t seem to work. Can someone please shed some light for me?


There is no such random variable for Nightbot. Instead you can use $(eval) to pick a random item. For example:

!addcom !slap $(user) slapped $(touser) with a $(eval a=[`stinky fish`,`television set`,`cactus`];a[Math.floor(Math.random()*a.length)])!

You can add more items to the array in the $(eval) code. Just be sure to keep the items bounded by backticks and separated by commas as shown.

Thanks! That worked! Is there a way to make the command randomly choose a viewer as well if someone were not to choose a user to “slap”? I mean like is there a way to have both options of choosing a user or randomly picking someone?

If a user is specified, the response will include that name, otherwise return a random viewer.

!addcom !slap $(user) slapped $(eval a=[`stinky fish`,`television set`,`cactus`];`$(user) slapped ${`$(query)`||`$(urlfetch$(channel))`} with a `+a[Math.floor(Math.random()*a.length)])!

You are AWESOME! Thank you so much for your help!

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