Complex Death counter, how to make it?

Hi, how is everyone? I’m very stupid with commands… And
I’m trying to use a death command for nightbot but i don’t know how…
I want an command that could keep count of the same game even if I did more than 1 stream and did a total count as well.
Ex:
“Died 6 times in Resident Evil 4! total deaths in other games: 4144”
And if i change game it would change as well and keep an log of the games that i already played and died with this counter…like " Died 2 times in Resident Evil 7! total deaths in other games: 4150"
And if i came back to Re4 it will count from 6 deaths … Dont know if i made it clear… I cant express myself very well in english, sorry…
there’s a way to do that?
Thanks everyone!!!

You may be able to find someone to write this code for you or you could try writing it yourself, but there’s no plug and play solution for this using Nightbot’s native commands and variables.

Here’s a set of commands that should do what you want:

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.

!adddeath

$(eval a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`,`);y=`token=PRIVATE_TOKEN&data=`;b=a[a.length-1].split(`|`);t=`$(twitch $(channel) "{{game}}")`;if(b[0]==t){c=y+(a.length-1)+`%20,`+t .replace(/\s/g,`%20`)+`|`+b[1]+`w`;d=`1`}else{d=y+`,`+t .replace(/\s/g,`%20`)+`|w`;c=`1`};c+` `+d)

set alias to _adddeath
set userlevel to moderator

_adddeath

$(eval a=`$(urlfetch https://twitch.center/customapi/editquote?$(1))`;b=`$(urlfetch https://twitch.center/customapi/addquote?$(2))`;`MESSAGE_YOU_WANT_WHEN_DEATH_IS_ADDED`)

set userlevel to moderator

!currentdeath

$(eval a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`,`);b=0;c=0;if(a[a.length-1].split(`|`)[0]==`$(twitch $(channel) "{{game}}")`){b=a[a.length-1].split(`|`)[1];c+=b.length};`$(channel) has ${c} deaths in $(twitch $(channel) "{{game}}").`)

displays total deaths in current game

!totaldeath

$(eval a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`,`);b=0;c=0;for(x=1;x<a.length;x++){b=a[x].split(`|`)[1];c+=b.length};`$(channel) has ${c} total deaths.`)

displays total deaths In all games

Note: I didn’t test these out they are just repurposed win commands so if you have any issues let me know.

1 Like

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