Need help with Wins and Kill counter

Okay so #22309 allows me to add 1 kill at a time but I need it to be able to add multiple ‘kills’ at a time since im using this as a match and points counter. Any solutions?

Hiya, please search the forums, there’s multiple different examples, for example: !wins Command with Kill Counter

I tried several with minor problems each time. The one you suggested I couldn’t get the !wins command to function properly. when I was able to I and a friend couldn’t figure out how to remove the K from the ‘kills’ per game

Better to post the command you were using then and ask for help with that, removing a letter from the response seems like an easy fix.

I see that now, I however had tried multiple codes and asked for help with the one i had used last. Since you recommend #21791 do you have any clue how to go about fixing the issue regarding the ‘k’ in the brackets of the !wins response

Maybe, or someone else might know. Can you explain how you want the command to look like, just the same output without the K ?

So im trying to get a counter that adds matches 1 at a time then points received after. So it would say Ren has played 2 matches with (13, 26) points. Im trying to make sure the code would work properly before adding it onto the person i mod fors nightbot since he plays fortnite arenas in the compete tab for say hype night. The post you linked has a ‘k’ after each number in the brackets due to it being for kills. So it is returning Ren has played 2 matches with (13K, 26K) points when the command does work as i believe there is a typo in that command as it does not work via copy/paste when i add the proper tokens in

So currently im using

> !addmatch $(eval a=parseInt(decodeURIComponent(`$(querystring)`),10);`redacted`+(a>=0?`&data=~${a}K~0~`:``))
> seems to work fine
> 
> !match $(eval a=`$(urlfetch https://twitch.center/customapi/quote/list?token=redacted)`.match(/~\d+K~/g);a?(b=a.length,c=`(`+a.map(x=>x.slice(1,x.length-1)).join(`, `)+`)`):(b=0,c=``);`$(channel) has played ${b} matches ${c}`)
> returns with 'Kanarenee has played 0 matches' everytime
> 
> _!addmatch $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;b=decodeURIComponent(`$(querystring)`);b.includes(`redacted`)?(a.includes(`Successfully added entry`)?`$(channel) played another match with ${b.split(`~`)[1].split(`K`)[0]} points!`:`Invalid input!`):`Use !addmatch`)

@RokettoJanpu this is originally your code do you have any ideas?

Hey @kanarenee!

Well, if you look at the code of #21791, it sends a K to the quote API, that’s where it comes from, however, it’s used to count, so removing such data would damage the command.

If however the K shows up and is an issue, you can use ${b.replace(`K`,``)}

So that would be fine regardless at this point im more concerned with the fact the code i have posted refuses to update itself via the entered data. The K is negligible and if i can get rid of it fine but as a whole the code doesn’t seem to want to work. Every variation of the counter that adds multiples doesn’t work either due to a typo i can’t find or other issues unknown to me. If you could help me troubleshoot the code i posted above that’d be grand

Alright, so I took the time to read the commands of #21791 as it’s the set of commands that looks to fit your needs the best, and there’s indeed an error in the !wins command where the last ` backtick is missing, but the rest works just fine!
So here’s the fix while Roketto updates his post:

!addcom !addwin -ul=mod -a=_addwin $(eval a=parseInt(decodeURIComponent(`$(querystring)`),10);`PRIVATE_TOKEN`+(a>=0?`&data=~${a}K~`:``))
!addcom _addwin -ul=mod $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;b=decodeURIComponent(`$(querystring)`);b.includes(`PRIVATE_TOKEN`)?(a.includes(`Successfully added entry`)?`$(channel) won another game with ${b.split(`~`)[1].split(`K`)[0]} kills!`:`Invalid input!`):`Use !addwin`)
!addcom !wins $(eval a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)`.match(/~\d+K~/g);a?(b=a.length,c=`(`+a.map(x=>x.slice(1,x.length-1)).join(`, `)+`)`):(b=0,c=``);`$(channel) has ${b} wins ${c}`)
!addcom !resetwins -ul=mod $(eval `$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`.includes(`All entries have been deleted`)?`Wins have been reset.`:`Try again later...`)

If you want to remove the K altogether from the command, here’s the fix:

!addcom !addwin -ul=mod -a=_addwin $(eval a=parseInt(decodeURIComponent(`$(querystring)`),10);`PRIVATE_TOKEN`+(a>=0?`&data=~${a}~`:``))
!addcom _addwin -ul=mod $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;b=decodeURIComponent(`$(querystring)`);b.includes(`PRIVATE_TOKEN`)?(a.includes(`Successfully added entry`)?`$(channel) won another game with ${b.split(`~`)[1]} kills!`:`Invalid input!`):`Use !addwin`)
!addcom !wins $(eval a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)`.match(/~\d+~/g);a?(b=a.length,c=`(`+a.map(x=>x.slice(1,x.length-1)).join(`, `)+`)`):(b=0,c=``);`$(channel) has ${b} wins ${c}`)
!addcom !resetwins -ul=mod $(eval `$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`.includes(`All entries have been deleted`)?`Wins have been reset.`:`Try again later...`)

The usage of the !addwin command is the following: at the end of each game, use it if you won, and specify the amount of kill you made during that game, so if I won a game with 5 kills: !addwin 5


Now, onto your commands… It seems like the error is caused by your !addmatch command, here:
&data=~${a}K~0~, the last 0~ is an issue in my opinion.


I would recommend using the commands from #21791 I updated above, with your text and without the K it would be:

!addcom !addmatch -ul=mod -a=_addmatch $(eval a=parseInt(decodeURIComponent(`$(querystring)`),10);`PRIVATE_TOKEN`+(a>=0?`&data=~${a}~`:``))
!addcom _addmatch -ul=mod $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;b=decodeURIComponent(`$(querystring)`);b.includes(`PRIVATE_TOKEN`)?(a.includes(`Successfully added entry`)?`$(channel) played another match with ${b.split(`~`)[1]} points!`:`Invalid input!`):`Use !addmatch`)
!addcom !match $(eval a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)`.match(/~\d+~/g);a?(b=a.length,c=a.map(x=>x.slice(1,x.length-1)).join(`, `)):(b=0,c=``);`$(channel) has played ${b} matches, points: ${c}`)
!addcom !resetmatch -ul=mod $(eval `$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`.includes(`All entries have been deleted`)?`Matches have been reset.`:`Try again later...`)
2 Likes

You’re a lifesaver, thanks for the help! This will definitely help with hype night and arena matches

1 Like

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