Okay so #22309 (link expired) 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?
Need help with Wins and Kill counter
14 replies
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`)
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 (link expired) 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}`)
Didn't find your answer? The community is on Discord.
Ask on Discord