RNG with set responses for a range of possible numbers

Hi, here is a solution I made that fixes this issue. This code also enables longer responses.

$(eval z=decodeURIComponent;const a=z("$(querystring $(user))"),{die:b,responses:c}=JSON.parse(z("$(querystring $(urlfetch json https://pastebin.com/raw/3bNSGLcG))")),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}`)

Note the https://pastebin.com/raw/3bNSGLcG link in the command. Visit this link and notice the structure of the text. "die": 20 specifies that the die has 20 sides. "8": "response c" specifies that any roll between 8 and the next number (in this case 14) will produce the response “response c”.

Now copy the text on that page. Visit https://pastebin.com and paste it into the box. Make your modifications to the responses or die numbers. You must take care to preserve the existing commas and quotes. Now click “Create New Paste”. You will be redirected to a new page with your paste. Notice the 8-character identifier present at the end of your browser’s address bar. Copy this identifier and replace the 3bNSGLcG in my code with yours. Now you are ready to add the command.

1 Like