Casino guesses!

I have a question for a friend! my friend is running a casino stream and whenever he’s doing a bonushunt he puts up a contest to see who can guess closest to the amount of money the bonus opening generated! simply asked is there a way to fix a contest like that so people can just typ !contest amount and that it automatically adds that to a list they can look at! thanks in advance!

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:


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:

$(eval z=`$(urlfetch$(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:
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+):

$(eval z=`$(urlfetch`;`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:

$(eval z=`$(urlfetch$(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.

$(eval q=decodeURIComponent(`$(querystring)`);c=`$(urlfetch json`.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+):

$(eval z=`$(urlfetch`;`Guesses cleared.`)

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