Daily and Weekly $(count) in the same command

Is it possible to get 2 count variables in 1 command but let both start from a different value?
e.g. !killed which would result in: “Streamer x is killed 5 times today and 36 times this week”

Thanks!

Hey @brecht_vh!

Yes, it’s possible, here’s how to:

First let’s set up the commands to display the message:

!addcom !killed -ul=mod -a=_killed $(count)

!addcom _killed -ul=mod $(channel) was killed $(query) times today and $(count) times this week.

Call !killed to update the counters.

Then, to reset the counters, here’s how:

!addcom !dayreset -ul=mod -a=!editcom !killed \-c=0

!addcom !weekreset -ul=mod -a=!editcom _killed \-c=0

To reset the daily counter, call !dayreset and to reset the full week counter call !weekreset.


UPDATE

I have been asked to make a version of it so viewers can check on the counters without adding to it, so here is the solution.

We’ll use the quote system API. You’ll get your TOKENS by clicking on the second link in the post, in the Manual Installation section, use these in the commands I wrote. To know where to look for your PUBLIC_TOKEN and PRIVATE_TOKEN, look at the field bellow:

$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=$(querystring))
$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(querystring))
$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&data=$(querystring))

Keep your PRIVATE_TOKEN secret, don’t share it anywhere. Add the following commands from the dashboard. Don’t use the chat as anyone could monitor it and copy the token, they could then edit your data.

So we’ll have a command to add deaths to the counter:
!adddeath:

$(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(time TIMEZONE "WW E|"))`;f=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=1&no_id=1)`.split(` `).shift();t=`$(time TIMEZONE "WW")`;f==t?` `:`PRIVATE_TOKEN&data=1`)

Make sure to set this command’s userlevel to Moderator.

Then the command to look at the counters without adding to them:
!deaths:

$(eval f=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=1&no_id=1)`.split(` `).shift();t=`$(time TIMEZONE "WW")`;f==t?` `:`PRIVATE_TOKEN&data=1`)

But these two commands don’t work alone, we need to set up an alias for them:
_deaths:

$(eval a=`$(urlfetch https://twitch.center/customapi/delquote?token=$(query))`;q=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`|`).join(` `);w=(q.match(/$(time TIMEZONE "WW")/g)||[]).length;d=(q.match(/$(time TIMEZONE "WW E")/g)||[]).length;`$(twitch $(channel) "{{displayName}}") died ${d} times today and ${w} times this week.`)

Make sure to add _deaths as alias of both !adddeath and !deaths.

As well as replacing PUBLIC_TOKEN and PRIVATE_TOKEN in the commands, you’ll also need to replace TIMEZONE by yours, you can consult the full list of supported timezones in the documentation.

To avoid overloading the Quote System the commands will delete the deaths from the previous week one by one every time you add a death or when someone consult the counters, it’ll stop deleting once it reaches the deaths from the current week, I made it this way as I believe there’s a limit on the amount of quotes, which means you’d have to clear the list from time to time if this system wasn’t in place, plus I don’t want to take space on servers with content that isn’t actual quotes.

1 Like

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