A custom !setwin/counter

So I’m trying to make a command for a few streamers I’m a mod for. What I am needing is a command that tracks their total wins for whatever specific game they want. For example " (User) has 12 wins this month and 245 total wins" I was trying to figure out if there is a way I can just do a !addwins 1 and itll just add to the wins this month and the total wins without having to put the exact number and changing it individually everytime.

So there are multiple counters for each game they play? Should the game be automatically determined by the command, will you enter the game after !addwins, or will you have multiple commands for each game?

If it is possible to have the game in the command as well that would be great. It will only be for 1 game (Fortnite). Just needing something that will allow me to set their current wins and then add 1 without having to manually input the exact number each time they get a win. (and of course a command that allows the viewers to see how many wins they have) (Apologies if this seems a bit vague or dumb. Still kind of new to this)

Can you give me an example?

" !setwins 12 165 " " !wins " Nightbot: Fortnite wins - This month 12, Total wins 165. Mod: !addwins 1 Nightbot: The command “!wins” has been edited successfully. " !wins " Nightbot: Fortnite wins: This month 13, Total wins 166. <- (If that makes any sense. I found a setwins command but it required me to type the wins in manually each time. so if I wanted to add a win to the streamers 12 this month and 165 in total I would have to type in !setwins 13 166. I don’t really mind doing that. I just wanted to know if there is a easier way to add the wins without manually inputting the exact number)

Go to https://twitch.center/customapi/quote/generate. You will see three lines. Your first token is after token= and before &data= on the first line. Your second token is after token= and before &data= on the second and third lines. Replace FIRSTTOKEN and SECONDTOKEN with these before you add the following commands.

!wins
$(eval allWins = `$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1)`.split(","); now = Date.now(); total = 0; thisMonth = 0; for (i = 0; i < allWins.length; i++){match = allWins[i].match(/^(\d+)\|(-?\d+)$/); if (match !== null){timestamp = parseInt(match[1]); wins = parseInt(match[2]); total += wins; if (now - timestamp < 31 * 86400000){thisMonth += wins}}} `Fortnite wins: This month: ${thisMonth}, Total wins: ${total}`)

!winsadd (alias to !winsadder, userlevel moderator)
$(eval wins = `$(query)` ? parseInt(`$(query)`) : 1; if (isNaN(wins)){"$INVALIDQUERY$"} else {"?token=SECONDTOKEN&data=" + encodeURIComponent(`${Date.now()}|${wins},`)})

!winsadder (userlevel moderator)
$(eval response = `$(urlfetch json http://twitch.center/customapi/addquote$(query))`; if (response.startsWith("Successfully added entry ")){"The number of wins was updated"} else if (`$(query)` === "$INVALIDQUERY$"){"Enter a number after !winsadd"} else {"Use !winsadd"})

!winsset (alias to !winssetter, userlevel moderator)
$(eval m=`$(query)`.match(/^(\d+) (\d+)$/);if(m===null){"$INVALIDQUERY$"}else{tM=parseInt(m[1]);t=parseInt(m[2]);if(tM>t){"$INVALIDQUERY$"}else{if(tM>0||t-tM>0){aQ="";if(tM>0){aQ+=`${Date.now()}|${tM},`}if(t-tM>0){aQ+=`0|${t-tM},`}"?token=SECONDTOKEN&data="+encodeURIComponent(aQ)}else{"?token=SECONDTOKEN&$RESET$"}}})

!winssetter (userlevel moderator)
$(eval cR=`$(urlfetch json http://twitch.center/customapi/delquote$(query)&clear=1)`;aR=`$(urlfetch json http://twitch.center/customapi/addquote$(query))`;if(aR=="Successfully added entry #1"){if(cR=="All entries have been deleted"){"The win counter was set"}else{`Error resetting (${cR})`}}else if(`$(query)`=="$INVALIDQUERY$"){"Enter the number of wins this month and the total number of wins after !winsset"}else if(`$(query)`.includes("$RESET$")){"The win counter was reset"}else{"Use !winsset"})

Commands:
!wins: Viewers type this to see this month’s (31 days) win count and the total win count.

!winsadd: Mods type this, followed by a number, to add to this month’s win count and the total win count. If no number is specified, then 1 is used. Each win is timestamped, so 31 days after being added, a win will no longer be counted in this month’s wins.

!winsadder: Utility command for !winsadd that shouldn’t be manually used.

!winsset: Mods type this, followed by this month’s win count, followed by a space, followed by the total win count, to set them. This completely erases what was added with !winsadd.

!winssetter: Utility command for !winsset that shouldn’t be manually used.

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