Auto update dailyWin & totalWin counter with one command

I have been trying to find this answer everywhere. I have seen multiple threads regarding win counters and most include a secondary variable. I used !wins Command with Kill Counter - #2 by RokettoJanpu to create a command to track wins. However, I do not wish to track kill count as well. Sure I can simply edit the output to not display the kill count per game, but I don’t want to have to type !addwin followed by a number every time I wish to add a win to the counter.

Idealistically I could have two variables:
!totalwins which would display $(channel) has a total of (###) (wins in lets say warzone)
!dailywins Which would display $(channel) has won (##) games today

Then I would have two commands
!addwin which would update !dailywins as well as !totalwins
and
!resetwins which would reset the number displayed in !dailywins to zero

The thread linked shows me how to set up most of that however I don’t know how to remove the kill count variable and need for it to be input also I would like !addwin to update both variables !dailywins and !totalwins. Thank you for your help
@RokettoJanpu @xgerhard were the two in the forum who I’ve seen kind of cover the topic not sure if either of you are able to help.

@potatoeaterlove I am going to test it right now and see how it responds, but is the timezone thing needed? If so what format would the input be I am CST; and instead of deleting the last win is it possible to reset the dailywins to zero? Also, its not working at all lol.

@potatoeaterlove I am still unable to use the code that you provided. The commands do not process correctly

Hey @D_Skizzle im sorry for the inconvenience I will test the code and fix it later today when I have some free time.

1 Like

Here are some new tested commands that should do exactly what you want.
You can find a list of time zones that nightbot allows here Time - Nightbot Docs

!addwin

$(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=`$(time YOUR_TOMEZONE "MMMM Do YYYY")`;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 _addwin
Set userlevel to moderator

_addwin

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

Set userlevel to moderator

!totalwin

$(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 wins.`)

!dailywin

$(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]==`$(time YOUR_TIMEZONE "MMMM Do YYYY")`){b=a[a.length-1].split(`|`)[1];c+=b.length};`$(channel) has ${c} wins today.`)

!resetwin

$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&data=$(eval a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=b27222f9&no_id=1)`.split(`,`);a.length-1))

Set alias to _resetwin
Set userlevel to moderator

_resetwin

MESSAGE_YOU_WANT_IT_TO_SAY_WHEN_WINS_RESET

Set userlevel to moderator

And before you ask it resets the whole day. Enjoy your commands <3

I thank you very much for your time and help with this. I will use them when I get home. I have very little experience with JavaScript which is why my troubleshooting was getting me nowhere. Thank you again for the help.

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