Hi there, I’ve been lurking in the forums to find answers to my problems, but this one has me completely stumped.
I’m making an Undertale-inspired !mercy command, I’m trying to get Nightbot to respond to a command with three potential outcomes:
- if $(user)==$(touser), a brief message (you can’t spare yourself), else…
- generate a number between 1 and 10. if(x<10) then poll pastebin for a random “idle” response, else (if x=10 then),
- a rare “YOU WON! You got 0 XP and (random number) gold.” message (1/10 chance to appear)
So basically, if the user doesn’t add an argument after the command, they’ll get response 1. But if they do, then theoretically, 9/10 times they’ll get response 2, or 1/10 times response 3.
I am able to get responses 1 and 2 work if I omit the 3rd option, like this:
* $(eval if("$(user)"=="$(touser)"){"$(user) tried to spare themself. But nothing happened."}else{"$(touser)"+"$(eval a="$(urlfetch json https://pastebin.com/raw/UmRNDXpa)".split("#");a[Math.floor(Math.random()*a.length)])"})
I’m also able to make it choose between responses 2 and 3 in isolation:
* $(eval var b=(Math.floor(Math.random()*11));if(b<10){"$(touser)"+"$(eval a="$(urlfetch json https://pastebin.com/raw/UmRNDXpa)".split("#");a[Math.floor(Math.random()*a.length)])"}else{"YOU WON! $(user) earned 0 XP and "+(Math.ceil(Math.random()*100))+" gold."})
However, when I put it all together and try !mercy Nightbot, I get either Unexpected token ')'
or missing ) after argument list
, OR it just displays raw code like:
* Nightbot$(urlfetch json https://pastebin.com/raw/UmRNDXpa)
I’ve tried using single vs. double quotes, and using if/else in different ways, but I just can’t get it to do what I want. Here’s what I’m currently working with:
* $(eval if('$(user)'=='$(touser)'){'$(user) tried to spare themself. But nothing happened.'}else{"$(eval var x=Math.ceil(Math.random()*10);if(x<10){$(touser)$(eval a='$(urlfetch json https://pastebin.com/raw/UmRNDXpa)'.split('#');a[Math.floor(Math.random()*a.length)])}else{'YOU WON! $(user) earned 0 XP and '+(Math.ceil(Math.random()*100))+' gold.'})"})
Any help would be greatly appreciated! I feel like I’m very close to getting it, but not quite there. Thank you!