How to deactivate random number if user selects number.

I have created a command for users to “gamble”.

!gamble $(user) gambles $(querystring) bolts and $(eval a=[“wins!”, “loses”];a[Math.floor(Math.random() * a.length)]) a user is able to “gamble” a number of bolts and they win or lose.

I have also created one with a random number

!gamble $(user) gambles $(customapi$(1)&end=$(2)) bolts and $(eval a=[“wins!”, “loses”];a[Math.floor(Math.random() * a.length)])

Can I make it so that a random number is selected only if there is no user selected number, but still allow people to select a number? I have been experimenting, but I am clueless with coding and how to integrate different things. Any help is very appreciated :slight_smile:

1 Like

Try this:

!addcom !gamble $(eval A=`$(1)`;if(A==`null`){B=Math.floor(Math.random()*RANDOM_NUMBER_AMOUNT+1)}else{B=A};C=[`wins!`,`loses.`];`$(user) gambles ${B} bolts and ${C[Math.floor(Math.random()*2)]}`)

Replace RANDOM_NUMBER_AMOUNT with the highest random number you want possible.

Thank you so much! That works perfectly!

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