Hey @siqrize!
If I understand well, your friend needs a way to store everyone’s guesses to determine who guessed right later on, is that right?
If so, that can be done with the quote system API. You’ll get your TOKENS
by clicking on the second link in the post, 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. To add a command containing your PRIVATE_TOKEN
do it from the dashboard. Don’t use the chat as anyone could monitor it and copy the token, they could then edit your data.
So first of all, you’ll have to create a !contest
command where people enter their guesses and it stores their name along with their guesses:
• !contest
:
$(eval z=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(user) $(querystring))`;`$(user): guess registered.`)
Then once the the bonus hunt is over, you can get the list of guesses and look through them here:
https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1
Or you can create a !guesses
command containing the link in it.
Then finally you would reset the guesses list before starting a new contest with the following command (make sure this command is for mods+):
• !resetcontest
:
$(eval z=`$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`;`Guesses cleared.`)
So that’s for the simple version…
Now let’s look at a more advanced solution.
You still have the !contest
command, but this time it’s slightly different:
• !contest
:
$(eval z=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(user)|$(querystring)|)`;`$(user): guess registered.`)
Then you have the !bonushunt
command where you enter the value of the bonus and the commands gets you the user(s) who is/are the closest.
• !bonushunt
:
$(eval q=decodeURIComponent(`$(querystring)`);c=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`|`);u=[];g=[];w=[];for(i=0;i<g.length;i++){isNaN(c[i])?u.push(c[i]):g.push(c[i]);}if(isNaN(q)){r=`Enter the bonus amount.`}else{n=g.reduce((a,b)=>Math.abs(b-q)<Math.abs(a-q)?b:a);for(j=0;j<g.length;j++){if(g[j]==n){w.push(u[j])}}r=`With a guess of ${n}, the winners are: ${w.join(` `)}. Congratulations!`}r)
The usage being: !bonushunt [amount]
And you should get as response: With a guess of {guess}, the winners are: {winner(s)}.
And then the command to reset the guesses, same as the one before (make sure this command is for mods+):
• !resetcontest
:
$(eval z=`$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`;`Guesses cleared.`)