I currently have this command:
$(eval
if(1==1){var code = “code1”;}else{var code = “code2”;}
var json = $(urlfetch json http://speedrun.com/api/v1/leaderboards/twwhd/category/ code variable here ?top=1&embed=players))
To get the current world record from a game.
Is it possible to put the “code” variable in the json url, if so how?
You have to nest the eval that calculates the URL part inside the urlfetch.
Know that if you need to use some other Nightbot variable inside the eval that calculates the URL part, you will have to use two commands (one an alias of the other) in order to circumvent the variable nesting limit.
$(eval var json = $(urlfetch json http://speedrun.com/api/v1/leaderboards/twwhd/category/$(eval if(1==1){"code1"}else{"code2"})?top=1&embed=players))