Declare Multiple Variables For Record Command

Hey, I’m trying to ease things up for mods, trying to make a !score command that returns the streamer’s win/loss count so far, should return Ex: Today's Record 4 W - 2 L, what I want to do is make it so that !win adds 1 point to the wins and !loss adds 1 point to the losses.

What I tried so far (which I suppose is not how you do this) for the win count and didn’t work:

!commands add !win -ul=moderator -a=!commands edit !score $(eval var W = `$(win)`; var L = `$(lose)`; `Today's Record ${W+1} W - ${L} L`)

and this for the lose count:

!commands add !loss -ul=moderator -a=!commands edit !score $(eval var W = `$(win)`; var L = `$(lose)`; `Today's Record ${W} W - ${L+1} L`)

when I use those !score just returns: Today's Record [invalid variable]1 W - [invalid variable] L and Today's Record [invalid variable] W - [invalid variable]1 L

Hey @karimawi!

I think this command is precisely what you’re looking for, you just need to adapt it to your needs a bit:

1 Like

I added those, they “work” but there’s a problem when resetting, I use !rst for the qoute and !wrst/!lrst for the count resets, I do all 3 to zero out everything, but then when I use !win or !lose it continues counting from where it was, aka !wrst/!lrst probably did not reset the count:

!addcom !win -ul=moderator -a=!score $(urlfetch https://twitch.center/customapi/addquote?token=REDACTED&data=w$(count))
!addcom !loss -ul=moderator -a=!score $(urlfetch https://twitch.center/customapi/addquote?token=REDACTED&data=l$(count))
!addcom !score $(eval q=`$(urlfetch json https://twitch.center/customapi/quote/list?token=REDACTED&no_id=1)`;w=q.match(/w\d+/g);l=q.match(/l\d+/g);w==null?w=0:w=w.pop().replace(`w`,``);l==null?l=0:l=l.pop().replace(`l`,``);`Today's Record: ${w} W | ${l} L`)

!addcom !wrst -ul=moderator -a=!editcom !win -c=0
!addcom !lrst -ul=moderator -a=!editcom !loss -c=0
!addcom !rst -ul=moderator $(urlfetch https://twitch.center/customapi/delquote?token=REDACTED&clear=1)

I see what might be the issue.
In the post I linked I assume you add commands through the dashboard, especially since I mentioned to do so for the commands that contain a PRIVATE_TOKEN.
But if you are adding the reset commands through the chat, then you need to add a back slash before the counter reset: \-c=0, so that on the dashboard the command’s message looks like !commandYouReset -c=0

1 Like

Thank you very much, works :+1:t2:. Don’t worry I always do these stuff while offline, when nobody’s in chat and I clear the chat afterwards, not the most secure way, but I prefer adding commands through chat.

1 Like

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