Hey @bellhidira!
Solution #1
Wouldn’t a math command be simpler?
!addcom !math -cd=5 $(eval b=decodeURIComponent(`$(querystring)`);if(b){try{`${b} = ${eval(b)}`;}catch(e){`Invalid mathematical expression!`;}}else{`There is no input...`;}})
Credit to @RokettoJanpu
Solution #2
Otherwise, to do what you’re asking for… We’ll use ehsankia’s quote system.
!addcom a -cd=5 $(eval if(isNaN(`$(query)`)==false){q=`$(urlfetch https://twitch.center/customapi/editquote?token=PRIVATE_TOKEN&data=1 $(query))`;`a = $(query)`;}else if(isNaN(`$(query)`)==true){a=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&no_id=1&data=1)`;b=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&no_id=1&data=2)`;try{`a $(query) = {$(eval a $(query))}`;}catch(e){`Invalid mathematical expression!`;}}else{` `;})
!addcom b -cd=5 $(eval if(isNaN(`$(query)`)==false){q=`$(urlfetch https://twitch.center/customapi/editquote?token=PRIVATE_TOKEN&data=2 $(query))`;`b = $(query)`;}else if(isNaN(`$(query)`)==true){a=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&no_id=1&data=1)`;b=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&no_id=1&data=2)`;try{`b $(query) = {$(eval b $(query))}`;}catch(e){`Invalid mathematical expression!`;}}else{` `;})
This way, if you type a 5 and b 9 and then do b - a it’ll give you b - a = 4 and a + b will give you a + b = 14, etc. Any type of mathematical expression being available.
However, with this system, you’ll have to initiate the quote system first, here’s how I recommend to do it:
!addcom !init -cd=5 $(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(query))
!init 0
!init 1
!delcom !init
Solution #3
Now, if you really want to use $(count) you’ll have to call a and b the number of time you need them to reach and you’ll need a way to reset them in case you want to get to a lower number than a and/or b currently are.
So let’s say you want a to be equal to 4 you’ll have to call a four times. But if a is equal to 7, then you’ll have to reset a first with a command such as !reseta.
Anyway, here’s how to do it:
!addcom a -cd=5 $(eval if(`$(query)`){a=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&no_id=1&data=1)`;b=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&no_id=1&data=2)`;try{`a $(query) = {$(eval a $(query))}`;}catch(e){`Invalid mathematical expression!`;}}else{q=`$(urlfetch https://twitch.center/customapi/editquote?token=PRIVATE_TOKEN&data=1 $(count))`;`a = $(count)`;})
!addcom b -cd=5 $(eval if(`$(query)`){a=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&no_id=1&data=1)`;b=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&no_id=1&data=2)`;try{`b $(query) = {$(eval b $(query))}`;}catch(e){`Invalid mathematical expression!`;}}else{q=`$(urlfetch https://twitch.center/customapi/editquote?token=PRIVATE_TOKEN&data=2 $(count))`;`b = $(count)`;})
!addcom !reseta -cd=5 -a=!editcom a \-c=0
!addcom !resetb -cd=5 -a=!editcom b \-c=0
But with this system, you’ll have to initiate the quote system first too, here’s how I recommend to do it:
!addcom !init -cd=5 $(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(query))
!init 0
!init 1
!delcom !init
For solutions #2 and #3
To get your PUBLIC_TOKEN (8 characters) and PRIVATE_TOKEN (16 characters), use the second link in ehsankia’s quote system post. Store your tokens somewhere safe to add them back in case the command is edited by mistake, you don’t want to lose them.
And don’t share your PRIVATE_TOKEN anywhere, that’s why I’d recommend adding a and b from your dashboard so you don’t share your PRIVATE_TOKEN in chat, in that case remove !addcom and -cd=5 from the command message, a and b would, of course, be the commands names. Same for !init.
The commands I wrote are in the order I recommend them, this means that solution #1 is the simplest one, and solution #3 is basically you complicating your life, but the solution #2 is a mess too, haha! But I can’t judge, choose the solution that seems best to you and best meet your goals.