Random number reply with quotes tied to certain values

Hello, i’m running this code:

!ran $(user), You are a $(eval Math.floor(Math.random() * 10) + 1)

wich works perfectly but I want to tie a certain text string reply to certain range of values… let’s say
1 ~ 3 You are x
4 ~ 6 You are y
7 ~ 9 You are z

How can I do that ?

I had a similar command so I edited it according to your same example. Where it says “p=r(1,9)” is the range of values ​​you want to add, in this case between 1 and 9

@$(user) You are $(eval r=(a,b)=> Math.floor(Math.random()*(b-a+1))+a; p=r(1,9); o=``; if(p>0){o=X}; if(p>3){o=Y}; if(p>6){o=Z};o)

1 Like

I get “not defined” after it prints either X, Y or Z

ex:
You are X is not defined

You could just use my code like this:

$(eval 
    r = Math.floor(Math.random() * 10);
    r <= 3 ? `You are x` :
    r <= 6 ? `You are y` :
    r <= 9 ? `You are z` : ``
)

I think i did it really simple so you understand it and can modify it yourself, if you have questions just ask ^^