Alright, sorry I was busy, I didn’t have time to look into your command…
As I mentioned before, we’ll use ehsankia’s 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.
First we’ll have a command to define the outcome of the fight, this is your !fight
command:
$(eval a=[`w`,`d`,`l`]; b=[`l`,`d`,`w`]; r=Math.floor(Math.random()*3); `$(user) ${a[r]}|$(touser) ${b[r]}|`;)
Then, to this !fight
command, we’ll add _fight
as an alias (put _fight
in the alias field of !fight
):
$(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(querystring))`; q=`$(query)`.replace(`|`,` `).split(` `); o=[`won by KO!`, `it's a draw: both fighters are down.`, `lost by submission...`]; `${q[0]} fought ${q[2]} and ${q[1]==`w`?o[0]:q[1]==`d`?o[1]:q[1]==`l`?o[2]:`ERROR`}`;)
And finally, to get an user’s statistics, here’s the !stats
command:
$(eval q=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`|`); u=[]; w=d=l=e=0; q.forEach(f => f==`$(user)`+f.slice(`$(user)`.length)?u.push(f.replace(`$(user) `,``))); u.forEach(g => g==`w`?w++:g==`d`?d++:g==`l`?l++:e++); `$(user) statistics - Wins: ${w} | Losses: ${l} | Draws: ${d}${if(e>0){" | ERRORS: "+e}}`;)
For the ranks there’s too much data to take in account, so I won’t set it up, learn JS and implement it yourself if you really want it.