Hello. I would like to create a double command one which indicates a percentage. XX is 80% a pirate. ($ (user) is a cracker at $ (eval Math.floor (Math.random () * 100) + 1)%) but I would like to add a sentence depending on the result. if result <30, between 30 and 50, between 50 and 70 between 70 and 90 and> 90, each possibility has a different answer.
Percentage and bot responses based on the result
7 replies
Hey @Eager Shrimp!
Here's a solution:
$(eval r=Math.floor(Math.random()*100)+1;o=`responseIfAboveOrEqualTo90`;if(r<90){o=`responseIfBetween70And89Included`} if(r<70){o=`responseIfBetween50And69Included`} if(r<50){o=`responseIfBetween30And49Included`} if(r<30){o=`responseIfBellow30`}`$(user) is a cracker at ${r}%. ${o}.`)
That's because you need to use at least two equal signs to make a comparison, one equal sign affects the value to the variable.
$(eval r=Math.floor(Math.random()*100)+1;o=`responseIfAboveOrEqualTo90`;if(r==92){o=`responseIfEqualTo92} if(r<90){o=`responseIfBetween70And89Included`} if(r<70){o=`responseIfBetween50And69Included`} if(r<50){o=`responseIfBetween30And49Included`} if(r<30){o=`responseIfBellow30`}`$(user) is a cracker at ${r}%. ${o}.`)
Didn't find your answer? The community is on Discord.
Ask on Discord