Help with *eval* [specific responses]

Asked Apr 15, 2020·1 reply·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.

Hello guys, how are you all?
I saw this command in a few posts and I couldn't understand very well, because my english is horrible. I tried it anyway and now I'm here.
I want to use a eval command in my stream that when a specific number is choosen it's typed a specific response:
$(eval Math.floor((Math.random() * 100))

When typed:
0 - "response a"
50 - "response b"
66 - "response c"
77 - "response d"
99 - "response e"
100 - "response f".

If that is possible, someone can help me? Or if there is a way to do it.
Thank you and have a nice day 😃

smiley.png

1 reply

Hey @Rusty Whale!

Pretty sure you're talking about this post:
/t/rng-with-set-responses-for-a-range-of-possible-numbers/1534600022816063510…

It's pretty simple, create a Pastebin (create an account first so you can go back an edit the paste later) with the following data:

{
"die": 100,
"responses": {
"0": "response a",
"50": "response b",
"66": "response c",
"77": "response d",
"99": "response e",
"100": "response f"
}
}

Then copy/paste the command they wrote, replacing XXXXXXXX with the id of your paste.

$(eval z=decodeURIComponent;const a=z("$(querystring $(user))"),{die:b,responses:c}=JSON.parse(z("$(querystring $(urlfetch json https://pastebin.com/raw/XXXXXXXX))")),d=(a=>Math.ceil(Math.random()*a))(b),e=((a,b)=>{const c=Object.keys(a).map(Number).sort((c,a)=>a-c);for(const d of c)if(b>=d)return a[d];throw new Error("responses")})(c,d);`${a} rolls the D${b} and hits a ${d}. ${e}`)