World Record command


#1

Hey everyone,
I currently use a command that looks like this:
$(eval j=$(urlfetch json https://www.speedrun.com/api_records.php?game=oot);t=Object.keys(j)[0];q=“Any%”;l=Object.keys(j[t]);for(i=0;i<l.length;i++){if($(query).toLowerCase()==l[i].toLowerCase())q=l[i]}r=j[t][q];h=Math.floor(r.time/3600);m=Math.floor(r.time%3600/60);s=Math.floor(r.time%3600%60);t+"'s “+q+” record is "+h+"h "+m+"m "+s+“s RTA by “+r.player+”!”)
This pulls the Ocarina of Time Any% wr from speedrun and its great but I’ve recently been thinking if there is a way to change the game also. This command currently defaults to Any% is no other data is given but the user can say type “!wr 100%” and get the 100% wr.
So would it be possible to have a command that defaulted to oot any% but if say I typed !wr sm64 120 Star would tell me the Super Mario 64 120 star wr?

Many Thanks


#2

It is doable, you just need to parse a user’s input for the game + record, pass the game into their api, and then parse the response for the record