[Custom API] Send variables to second urlfetch

I have the following command which reads a timestamp from the first urlfetch and compares it to a set time (30minute duration) and then posts ${m} mins and ${s} secs remaining into chat. I need to push the ${m} and ${s} out to a second urlfetch but I cannot get it to work. Here is the code I have right now…

$(eval q=$(urlfetch http://twitch.center/customapi/quote?token=1stTOKEN&data=1&no_id=1),m=q.match(/^(.+)|\d+$/),m?(t=parseInt((new Date(m[1])-new Date)/1e3),t<=0?“Complete.”:(m=Math.floor(t/60)%60,s=t%60,(m>0? ${m} min:"")+(s>0? ${s} sec $(urlfetch https://twitch.center/customapi/editquote?token=2ndTOKEN&data=1&no_id=1 ${m} min ${s} sec):""))):q==""?"":"")

Nightbot variables evaluate inner to outer, so the urlfetch in the JS string is already evaluated before the JS is run by the eval. What you can do is set this command as an alias of another command which runs a urlfetch on the input to add the timestamp to the list then outputs the timestamp.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.