Would it be possible to make a command whose response changes depending on a percentage?

Asked Mar 20, 2020·2 replies·Last activity 6 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hi,
First of all, sorry for my English, I'm learning it

I'm trying to make a command that responds differently depending on the percentage that comes out in that same command, but I don't know how to do it.

This is the command:! Love There is a $ (customapi http://2g.be/twitch/randomnumber.php?=defstart=1&defend=100)% chance of love between $ (user) and $ (touser)

Is it possible to get him to say 4 different sentences at the end of the answer?

for example: if less than 25% come out saying one thing, between 25 and 50 another, between 50 and 75 another, and between 75 and 100 another

Thanks in advance

2 replies

Generating random numbers is quite easy using $(eval) so I'm using that instead of the custom API. Go through the command code and edit the various responses as you wish.

$(eval a=Math.ceil(Math.random()*100);`There is a ${a}% chance of love between $(user) and $(touser). `+(a<25?`less than 25% response`:(a<50?`between 25% and 50% response`:(a<75?`between 50% and 70% response`:`between 75% and 100% response`))))

Thank you very much for your help, it has been very useful to me