So I'm trying to make a sort of chat game where users can grab other users with a percent chance to fail. i also want nightbot to record the successes and failures using the quote_system api so that i can bring up a score board later. However, when ever the !grab command runs it seems to be running the api in both branches and adding to both success and failure regardless of result. Is there a way to have it only run the api in one branch?
$(eval v='$(user)'; u=$(query); t = ['0', '0', '0', '1', '1', '1', '1', '1', '1', '1']; a=t[Math.floor(Math.random() * t.length)]; if(a=='1') {$(urlfetch https://twitch.center/customapi/addquote?token=mytoken&data=grabS); v+' grabbed '+u+' successfully!';} else {$(urlfetch https://twitch.center/customapi/addquote?token=mytoken&data=grabF) ; u+' resisted '+v+'\'s grab!';})