Random responses

Hey, I wanna make my bot reply with a random response. It may be a simple % like !alien : “you are 45% alien” so random % from 0 to 100. Or only 2 responses like !hand : “You have only 1 hand” “you have 2 hands” (it’s just examples out of my head xD). And it will be chosen by the bot randomly.
How could I do it? I found Variables but there is nothing similar to what I want. The section Arguments seemed to be that, but I’ve no idea how it works, tried so many times and it shows I did sth wrong.
Thanks in advance!


The $(eval) variable lets you run JavaScript code. This variable allow for creating much more dynamic command responses. For example, it can be used to randomize responses and pick one response at random out of multiple possible ones.

For the !alien command:

You are $(eval Math.floor(Math.random()*101))% alien.

For the !hand command:

You have $(eval Math.ceil(Math.random()*2)<2?`1 hand`:`2 hands`).
1 Like

Thank you so much, everything works great! And if I want more responses for the 2nd one (3 for example), I need to write the line (Math.random()*3)<3? right? and one more response in the end.

I rewrote the command response for !hands to be a little more flexible. Replace MAXIMUM_NUMBER with the largest possible number you want the command to generate.

You have $(eval a=Math.ceil(Math.random()*MAX_NUMBER);a>1?`${a} hands`:`1 hand`).

Thank you! I’ll try it out. The world won’t forget you xd

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