Making a random percentage command better. need help

So im a moderator for a twitch channel and we’ve got a command that i want to make better.

currently you type the command “!happy” and it will say you are a random (0-100%) happy.

Is it possible to expand on the idea and for nightbot to categorize certain percentage groups with a different msg?

for example if you get 100% you will receive a special msg. Or perhaps a different msg if you land between 25%-50% etc.

1 Like

This handles cases, and you can add more cases as shown.

$(eval a=Math.floor(Math.random()*101);if(a<25){`msg1`;}else if(a>=25&&a<=50){`msg2`;}else if(OTHER CONDITION){`etc`;}else{`fallback msg`;})
1 Like

How do i get the command to show what percentage that it pulled? I got this string to work properly but its only showing the msg, not the reason for the specific msg (the specific percentage)

This shows the # and related msg.

$(eval a=Math.floor(Math.random()*101);if(a<25){b=`msg1`;}else if(a>=25&&a<=50){b=`msg2`;}else if(OTHER CONDITION){b=`etc`;}else{b=`fallback msg`;}`$(user) is ${a}% happy. ${b}`)
1 Like

May I ask what the command is now? I’m looking to do something similar but cannot find an example of it. Thank you.

Hey @a_yates21!

I mean, is the example above not enough?

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