Make a ($query) default if no input is given

Hi everyone,
I use a !wr command that works great and pulls data from an api but it requires an input such as !wr Any% for it to work.
What I was wondering is if there is any way to make the ($query) default to say Any% if no extra data is given?
The full command looks like this:
$(eval json=$(urlfetch json https://www.speedrun.com/api_records.php?game=mm); title = Object.keys(json)[0]; record=json[title]["$(query)"]; hours = Math.floor(record.time / 3600); minutes = Math.floor(record.time % 3600 / 60); seconds = Math.floor(record.time % 3600 % 60); title + "'s $(query) record is " + hours + "h " + minutes + "m " + seconds + "s RTA by " + record.player + “!”)

Thanks

This command uses Any% by default but switches to the user’s requested record if it is provided and exists.

$(eval j=$(urlfetch json https://www.speedrun.com/api_records.php?game=mm);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 topic was automatically closed 14 days after the last reply. New replies are no longer allowed.