Declare Multiple Variables For Record Command

Asked Jul 1, 2022·4 replies·Last activity 4 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

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:

javascript
!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:

javascript
!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

4 replies

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:

javascript
!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

Thank you very much, works 👍🏻. 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.