Nightbot command for only removing 1 on counter not reset

We’ve set up a death counter using this threads commands:

We have a working !adddeath and !deaths command but we are trying to create one that only takes 1 count away from the total rather than resets the entire total. E.g. 10 deaths to 9 with the use of a command rather than 10 deaths to 0.

Can anyone help please?

Hey @vroseria!

$(count) can only go up or be set to a specific value—aka a reset, you can’t substract a a specific value from it, sorry.

To do something like that you’ll need a more custom counter like one through the use of the qoute api I can set up a simple version for you later tonight when I have free time.

1 Like

Edit

I recommend this newer/easier version of the command


Here you go

To generate your tokens go here https://twitch.center/customapi/quote/generate they come in between token= and &data= the 8 digit one is your public and the 16 digit one is your private.

!counter this checks the counter.

$(eval a=`$(urlfetch https://twitch.center/customapi/quote/list?token=Public_Token&no_id=1)`;a!=`There are no quotes added`?`There is ${a.split(` `)[0]}${a.split(` `)[1]} deaths`:`There is 0 deaths`)

!add adds to the counter defaults to one

$(eval a=`$(urlfetch https://twitch.center/customapi/quote/list?token=Public_Token&no_id=1)`;c=1;if(parseInt(`$(1)`)==parseInt(`$(1)`)+0){c=$(1)}else{c=c};b=``;if(a==`There are no quotes added`){f=``;e=`add`;a=0}else{f=`1%20`;e=`edit`;a=parseInt(`${a.split(`,`)[1].split(` `)[0]==`plus`?``:`-`}${a.split(`,`)[1].split(` `)[1]}`)};if(a>=0){b=`plus`}else{b=`minus`};`${e}quote?token=Private_Token&data=${f},${b}%20${Math.floor(a+c)} ${c}`)

Set alias to _add

_add

$(eval a=`$(urlfetch https://twitch.center/customapi/$(1))";b="$(urlfetch https://twitch.center/customapi/$(1))`;`You added $(2) to the death counter`)

!subtract subtracts from the counter defaults to one

$(eval a=`$(urlfetch https://twitch.center/customapi/quote/list?token=Public_Token&no_id=1)`;c=1;if(parseInt(`$(1)`)==parseInt(`$(1)`)+0){c=$(1)}else{c=c};b=``;if(a==`There are no quotes added`){f=``;e=`add`;a=0}else{f=`1%20`;e=`edit`;a=parseInt(`${a.split(`,`)[1].split(` `)[0]==`plus`?``:`-`}${a.split(`,`)[1].split(` `)[1]}`)};if(a>=0){b=`plus`}else{b=`minus`};`${e}quote?token=Private_Token&data=${f},${b}%20${Math.floor(a-c)} ${c}`)

Set alias to _subtract

_subtract

$(eval a=`$(urlfetch https://twitch.center/customapi/$(1))";b="$(urlfetch https://twitch.center/customapi/$(1))`;`You subtracted $(2) to the death counter`)
1 Like

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