Wins, losses and draws count code, need help

I am using the code shown below.

  • !addcom -ul=moderator !addwin $(eval a=$(urlfetch http://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=win);) $(channel) just won! rooPog

  • !addcom -ul=moderator !addloss $(eval a=$(urlfetch http://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=loss);) $(channel) just lost! rooCry

  • !addcom -ul=moderator !adddraw $(eval a=$(urlfetch http://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=draw);) $(channel)'s game ended in a draw! rooBlank

  • !addcom -cd=5 !score $(channel) has $(eval a=$(urlfetch json http://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN);a.match(/win/g)!=null?w=a.match(/win/g).length:w=0;a.match(/loss/g)!=null?l=a.match(/loss/g).length:l=0;a.match(/draw/g)!=null?d=a.match(/draw/g).length:d=0;w+wins,+l+losses, and+d+draws.)

But, i want to implement a command that adds an arbitrary number to each of win, lose, and draw.

Ex)
cmd) !score
ans) 0 wins, 0 losses, and 0 draws.
cmd) !addwin
cmd) !score
ans) 1 wins, 0 losses, and 0 draws.
cmd) !addwins 2 (Desired command ,the same goes for losses and draws.)
cmd) !score
ans) 3 wins, 0 losses, and 0 draws.
cmd) !decwins 2 or !addwins -2 (Desired command ,the same goes for losses and draws.)
cmd) !score
ans) 1 wins, 0 losses, and 0 draws.

Thanks you!

@eco

New command setups for !addwin, !addloss, !adddraw, and !score. Replace PRIVATE_TOKEN with your private token and PUBLIC_TOKEN with your public token.

!addcom -ul=mod !addwin $(eval a=`$(urlfetch http://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=1W)`;a.includes(`Successfully added entry`)?`$(channel) just won! rooPog`:`Try the command again...`)

!addcom -ul=mod !addloss $(eval a=`$(urlfetch http://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=1L)`;a.includes(`Successfully added entry`)?`$(channel) just lost! rooCry`:`Try the command again...`)

!addcom -ul=mod !adddraw $(eval a=`$(urlfetch http://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=1D)`;a.includes(`Successfully added entry`)?`$(channel)'s game ended in a draw! rooBlank`:`Try the command again...`)

!addcom -cd=5 !score $(eval a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)`;w=a.match(/-?\d+W/g);w=w?w.reduce((y,z)=>y+parseInt(z),0):0;l=a.match(/-?\d+L/g);l=l?l.reduce((y,z)=>y+parseInt(z),0):0;d=a.match(/-?\d+D/g);d=d?d.reduce((y,z)=>y+parseInt(z),0):0;`$(channel) has ${w} wins, ${l} losses, and ${d} draws.`)

Setups for !addwins (aliased to _addwins), !addlosses (aliased to _addlosses), and !adddraws (aliased to _addraws). Replace the tokens accordingly.

!addcom -ul=mod !addwins -a=_addwins $(eval a=parseInt(decodeURIComponent(`$(querystring)`),10);`PRIVATE_TOKEN`+(!isNaN(a)?`&data=${a}W`:``))

!addcom -ul=mod _addwins $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;b=decodeURIComponent(`$(querystring)`);b.includes(`PRIVATE_TOKEN`)?(a.includes(`Successfully added entry`)?`Successfully added ${b.split(`=`)[1].replace(`W`,``)} wins!`:`Try again...`):`Use !addwins`)

!addcom -ul=mod !addlosses -a=_addlosses $(eval a=parseInt(decodeURIComponent(`$(querystring)`),10);`PRIVATE_TOKEN`+(!isNaN(a)?`&data=${a}L`:``))

!addcom -ul=mod _addlosses $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;b=decodeURIComponent(`$(querystring)`);b.includes(`PRIVATE_TOKEN`)?(a.includes(`Successfully added entry`)?`Successfully added ${b.split(`=`)[1].replace(`L`,``)} losses!`:`Try again...`):`Use !addlosses`)

!addcom -ul=mod !adddraws -a=_adddraws $(eval a=parseInt(decodeURIComponent(`$(querystring)`),10);`PRIVATE_TOKEN`+(!isNaN(a)?`&data=${a}D`:``))

!addcom -ul=mod _adddraws $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;b=decodeURIComponent(`$(querystring)`);b.includes(`PRIVATE_TOKEN`)?(a.includes(`Successfully added entry`)?`Successfully added ${b.split(`=`)[1].replace(`D`,``)} draws!`:`Try again...`):`Use !adddraws`)

@RokettoJanpu

When you set up a night bot, you were very helpful to me.
The answer to my question also showed the result I wanted, and I am very satisfied.
You are God.
Thank you for your reply.

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