Nightbot Random Chance Command?

My question is, is it possible to create a command for Nighbot with a 50/50% chance?
when i use !cookie nighbot answers 1 of 2 things either “GZ u won a cookie” or “bad luck, u lost your money”

Is it possible to create such command? If the answer is yes, please tell me how, i searched for a long time and didn’t find anything like this, only RNG.

And please tell me how to create this command.

Thanks for every answer!


You need an RNG (random number generator) to set up a command that outputs one of multiple responses at random. Copy and paste the following setup into your chat to create a !cookie command.

!addcom -cd=5 !cookie $(eval Math.round(Math.random())==0?`GZ u won a cookie`:`bad luck, u lost your money`)

This method returns a random float (decimal) between 0 and 1:


Nesting it inside this other method rounds the float to the nearest integer:


If the rounded number is equal to 0, Nightbot outputs one of the two responses. If it’s equal to 1, Nightbot outputs the other response.

1 Like

Another question: is it possible to use more than 2 responses with that command? Or is it necessary to change something?

For more than 2 possible responses, you need to use some other code.

!addcom -cd=5 !cookie $(eval a=[`GZ u won a cookie`,`bad luck, u lost your money`,`some other response`];a[Math.floor(Math.random()*a.length)])

Note that you can add more responses. Just make sure each response is separated by commas and bounded by backticks as shown in the code above.

1 Like

Okay BIG Thank you! You help me a lot. Dont stop with that! :smiley:

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