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.
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:
Math.random()
Nesting it inside this other method rounds the float to the nearest integer:
Math.round(Math.random())
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.