I want to make an addition function by applying function $(count)

@bellhidira

Just like the solutions posted above, this solution is possible using ehsan’s quote API.


Command Setups

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 and keep them somewhere safe!

I’ve set up 3 commands below:
!setvalue and _setvalue which work in tandem to declare number variables
!math which calculates an expression

Copy and paste the following command setups into chat. Replace PUBLIC_TOKEN with your public token and PRIVATE_TOKEN with your private token.

!addcom -cd=5 !setvalue -a=_setvalue $(eval a=decodeURIComponent(`$(querystring)`).match(/[A-Za-z]\w*\s?=\s?[+-]?(\d*[.])?\d+/g);`PRIVATE_TOKEN&data=${encodeURIComponent((a?a.join(`,`):`"e"`)+`;`)}`)

!addcom -cd=5 _setvalue $(eval d=decodeURIComponent;a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;b=d(d(`$(querystring)`));if(b.includes(`PRIVATE_TOKEN`)){c=b.split(`&data=`)[1].split(`,`).map(a=>a.split(`=`)[0].trim()).join(`, `);c!=`"e";`?`Successfully set values for: ${c}`.slice(0,400):`Failed to set any values!`;}else{`Use !setvalue`;})

!addcom -cd=5 !math $(eval _=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`;if(_!=`There are no quotes added`){eval(_);}__=decodeURIComponent(`$(querystring)`);if(__){try{`${__} = ${eval(__)}`.slice(0,400);}catch(e){`Invalid mathematical expression!`;}}else{`There is no input...`;})

Declaring Variables

To declare a number variable, type:

!setvalue VARIABLE_NAME = VALUE

where VARIABLE_NAME is your variable name and VALUE is the numeric value of the variable. VALUE can be any integer or float (decimal number).

An example of declaring a variable “a” with a value of 42:

!setvalue a = 42

You can declare multiple variables in one go. For example, declaring variables “first_number” and “second_number” with the values 420 and -3.14159, respectively:

!setvalue first_number = 420 second_number = -3.14159

You can exclude the spaces surrounding the “=” symbol if you wish. I only put in spaces to make the command usage examples easier to read. For example:

!setvalue first_number=420 second_number=-3.14159 

Once variables are declared, they retain their value between command uses. Re-assigning variables is permitted.


Calculating Expressions

The command to calculate expressions is:

!math [expression]

An example of using !math

!math 2+2

which will return:

2+2 = 4

Let us declare variables “a” and “b” with the values 3 and 4, respectively. First type:

!setvalue a = 3 b = 4

Now if you add “a” and “b”

!math a+b

This will return:

a+b = 7
1 Like