Multiple counters

Is there a way to have multiple counters similar to $(count), but dependent on the arguments you give the command, so there are 2 or more counters running?


I’m thinking of setting up one command that controls multiple counters, where, for example, you have a command called !counter and you type this to trigger one such counter:

!counter [counter order number]

Typing !counter 1 increments the first counter, !counter 2 increments the second counter, and so on. Is this what you have in mind? If so, would you rather have the command only be able to control up to a certain number of counters or be able to control an infinite number of counters?

Alternatively, I could set up two commands, !counter and !addcount, where !counter only shows the value of a certain counter and !addcount increments the value of a certain counter. Let me know whether you would like one command that both increments and shows the new value of a counter or two separate commands to show and increment counters.

1 Like

Thank you for the tips!
I want it to be able to use an arbitrary amount of counters.
The bigger problem is: can i call this command using $(eval) inside the javascript code?

The solution I’m thinking of doesn’t actually use $(count) variables; rather it uses a combination of $(eval) and ehsan’s quote API in a $(urlfetch). Also, would you rather have one command to increment then show a counter’s new value or have two separate commands, one to show a counter value and the other to increment the value?

Thanks for your steady replies!
I am looking for one command that both increments and shows the new value. The quote API seems promising for this indeed.

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 have set up 2 commands below, !counter and _counter which work in tandem to increment a selected counter (only !counter is meant to be used directly). Copy and paste each setup into chat one by one to add the commands. Replace PUBLIC_TOKEN with your public token and PRIVATE_TOKEN with your private token.

!addcom -cd=5 !counter -a=_counter $(eval a=parseInt(decodeURIComponent(`$(querystring)`));a>0?`PRIVATE_TOKEN&data=~${a}~ ${a}`:` `)

!addcom -cd=5 _counter $(eval a=`$(urlfetch$(1))`;b=`$(urlfetch json`;a.startsWith(`Successfully`)&&b!=`[Error Connecting to WebProxy Service]`&&decodeURIComponent(`$(querystring)`).includes(`PRIVATE_TOKEN`)?`The value of counter #$(2) is now ${b.match(/~$(2)~/g).length}`:`Error!`)

Command usage:
!counter [order number of the counter that you want to increment]

You are amazing! thank you so much!!

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