Adding a command that adds the amount specified to a counter

As the title says, I want a command that adds the amount I enter into the counter. Something like !add 5000, and it would add 5000. So when I type !counter it would show 5000.

@one_winged_devil

The following uses ehsan’s quote API.


Click this link. It will generate three links and two tokens, a public token (8 characters long) and a private token (16 characters long). The public token is located within the first generated link. The private token is located within both the second and third generated links. The tokens are found after token= and before &data=$(querystring) Copy them down and keep them somewhere safe!

I set up 3 commands below, !counter which shows the total counter value, !add (mod-only) which adds values to the counter, and !reset (mod-only) which resets the counter. Copy and paste the following command setups into chat one by one to add the commands. Replace PUBLIC_TOKEN with your public token and replace PRIVATE_TOKEN with your private token.

!addcom -cd=5 !counter $(eval a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`~`);a.unshift(0);`The counter value is ${a.reduce((b,c)=>b+parseInt(c)||b)}`)

!addcom -ul=mod !add $(eval `$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=~$(querystring))`.includes(`Successfully`)?`$(user) has added "${decodeURIComponent(`$(querystring)`)}" to the counter.`:`Try again...`)

!addcom -ul=mod !reset $(eval `$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`==`All entries have been deleted`?`$(user) has reset the counter!`:`Try again...`)

Note that !add will let you add any integer to the counter. This includes positive whole numbers, zero, and negative whole numbers. Also note that even if you accidentally add any non-numeric phrases to the counter, the !count command will ignore them.

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