I creating vote system

I am creating a voting system with the nighbot I want when users put messages “1” in youtube chat I need to count that and make percent and show to API that percent number

I want to put 3 options when user put “1” in chat make percent 0 - 100% if user put “2” make percent 0 - 100% and also when user put message “3” make 0 - 100% and I want to show in my stream that numbers from API?

It is only one vote example “3” only show 100% to that 3 option and for “1” “2” put 0%
Is that Possible?

Hiya, I dont really know what you are trying to make, however have a look at $(urlfetch) or $(eval), you can create your own scripts and calculate the right percentages.


Hi xgerhard

I want to make a script like this website: poll.ma.pe but for youtube poll

Hey @Jackob!

It was hard to understand, but I think I get what you want.

First of all, let me redirect you towards a solution that is already existing with Nightbot: https://docs.nightbot.tv/commands/poll
I would personally recommend this solution.

Now if you want something custom, keep reading.
Have you read the first link I sent before? Please do.

This solution isn’t 100% accurate as not every vote entry will be taken in account because of Nightbot’s cooldown.

One way you could do this is by using 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.

Then the voting commands are:

$(eval z=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=a)`;` `)


$(eval z=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=b)`;` `)


$(eval z=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=c)`;` `)

For the result command (make sure it’s for mods+):
!pollresults (for Twitch)

$(eval q=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`;a=q.match(/a/g);b=q.match(/b/g);c=q.match(/c/g);a==null?a=0:a=a.length;b==null?b=0:b=b.length;c==null?c=0:c=c.length;t=a+b+c;`Poll results: 1 → ${Math.round(a*100/t)}% | 2 → ${Math.round(b*100/t)}% | 3 → ${Math.round(c*100/t)}%`)

But since you’re on YouTube we’ll have to use Pastebin to work around the characters limit:


$(eval q=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`;e=`$(urlfetch json https://pastebin.com/raw/XXXXXXXX)`;eval(e);`1 → ${a}% | 2 → ${b}% | 3 → ${c}%`)

Create an account, then create a paste with no expiration date, and paste the following code in it:


Then replace XXXXXXXX in the command by the paste ID in the URL.

And finally to reset the poll (to run before each new poll, make sure it’s for mods+):

$(eval z=`$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`;`Poll reset`)
1 Like

Thank you for replay!
I am making Match Voting System.

Maybe can this work, i have some questions

  1. If is possible to I want to instead of run command “!pollresults” is possible to maybe make a realtime update results, that i dont need to run command !pollresults every time because i want to all my stream have results realtime is that possible?
  2. How much is nightbot countdown?

You can add !pollresults as an alias to 1, 2, and 3 for an update in “real time”, well every 5 seconds, since it’s Nightbot’s cooldown, which also means you’ll record 1 vote every 5 seconds, and it’ll just pollute your chat. That’s the reason why I’m heavily recommending the first solution instead of this one, plus you’ll be able to display the results in true real time by capturing the browser tab with the poll results.

1 Like

Yes i know that is better option for first one but a lot of people want to type only 1,2,3 in chat, and a lot of users dont understood that need to type command with !, for me second option is easy for users

I have one more question

  1. Is possible to add some space between numbers in paste-bin? Have i need only put blank space or need some code in it to make space?

With the first option the users would just need to click on the link and vote there, there’s nothing simpler than that.

And to answer your question, yes it is, but in our case here it’s just code, so it’s pointless.

1 Like

One more question i trying to find PUBLIC_TOKEN and PRIVATE_TOKEN
I dont know do i need to create application app and get that public Client id secret Client id? Is that PUBLIC_TOKEN and PRIVATE_TOKEN

Read my first answer, I’ve explained everything. If you can’t figure it out, use the first option, which is better in my opinion anyway, it’s easy to click on a link, your viewers aren’t dumb.

1 Like

Thank you for help I see now link for tokens, if this not work well for me I will switch to your first option
Anyway, Thank you again for very big help!! :grinning: :grinning:

Anytime, have fun with it!

1 Like

Sorry i have one more question i am now looking this code on pastebin, the bot only read that command on pastebin and post back to youtube chat results?
But i dont know is possible to post result not in youtube chat i need on specific website to post results from 1,2,3? because i want to post result in my stream not in chat?

With this option, the results can only be displayed in the chat.

If you want to display the results in your stream use the first option, as I said before, you can capture the browser tab with the poll results this way.

I see i will use first option anyway, thank you for help

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