Percentages with 6 different messages depending on number

I’m trying to make a command that generates a random percentage, and depending on the percentage, a different message gets attached. I’ve looked everywhere for how to do this but the best I found split the percentages into 3 instead of 6.

Percentages I’d like to get a different message for (while still showing the percentage):
0
1-24
25-49
50-74
75-99
100

The character limit also ends up limiting my command, so I’m guessing I have to use a pastebin for this at some point? I’ve tried a lot and I’m really struggling pretty badly so any help would be greatly appreciated!

You could try this:

$(eval j=decodeURIComponent("$(querystring $(urlfetch json https://pastebin.com/raw/GftYNvBh))");try{l=Object.entries(JSON.parse(j));l.sort(([x],[y])=>x-y);n=Math.floor(Math.random()*101);m=l.find(([s],i)=>n>=s&&(i==l.length-1||n<l[i+1][0]))?.[1];`You rolled ${n}: ${m??'No message'}`}catch(e){`Failed to parse messages: ${e.message}: ${j}`.slice(0,400)})

See https://pastebin.com/raw/GftYNvBh for how to write the messages. Make your own Pastebin paste with your messages and replace the paste ID in the command above with yours.

How to write your messages in your Pastebin paste
{
    "0": "0 message",
    "1": "1-24 message",
    "25": "25-49 message",
    "50": "50-74 message",
    "75": "75-99 message",
    "100": "100 message"
}
1 Like

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