A pastebin command with variables for the second half

Asked Feb 20, 2023·1 reply·Last activity 3 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.

hi can someone help me with this command i found and worked on

!editcom !battle A wild $(user) appears & attacks $(touser)! $(user) uses $(eval a=$(urlfetch json https://pastebin.com/raw/Ap6zNgF3);a[Math.floor(Math.random()*a.length)]). $(eval var a=["It misses...","It's super effective! $(touser) faints","It's not very effective... "]; a[Math.floor(Math.random()*a.length)];)!

The command works all the way to the link. But the rest doesnt work out

1 reply

Hey @Bashful Frog!

If you use more than one $(eval) you're doing something wrong, everything can be contained in one, and it also helps speed up the execution of your code, here's a fix:

!addcom !battle $(eval u = '$(user)'; t = '$(touser)'; r = a => a[Math.floor(Math.random() * a.length)]; s = $(urlfetch json https://pastebin.com/raw/Ap6zNgF3); o = [`It misses...`, `It's super effective! ${t} faints`, `It's not very effective...`]; `A wild ${u} appears & attacks ${t}! ${u} uses ${r(s)}. ${r(o)}`;)

I think your issue with the second part of the command was that you were using the wrong quotation marks: “” instead of "", '' or `` ``.