Announce votes in Discord

Paste one address and every counted vote is posted. The second half shows signed webhooks for your own systems.

What you need

  • Permission to edit a Discord channel
  • Or an https address of your own

Create a channel webhook

In Discord, open the settings of the channel, then Integrations, then Webhooks. Create one and choose Copy Webhook URL.

Paste it into VoteScript

Open Webhooks, paste it into Discord channel and save.

Send a test

Press Send a test and look at the channel.

You should now see: A test message, and later one line for each vote.

Optional: your own system

Put an https address into Send votes to. Check the signature with the secret that appears on the page: HMAC-SHA256 over the raw body.

hook.php
<?php
$body = file_get_contents('php://input');
$sig = 'sha256=' . hash_hmac('sha256', $body, 'YOUR_SIGNING_SECRET');
if (!hash_equals($sig, $_SERVER['HTTP_X_VOTESCRIPT_SIGNATURE'] ?? '')) {
    http_response_code(403);
    exit;
}
$vote = json_decode($body, true);   // remember $vote['id'], ignore it the second time
http_response_code(204);
hook.mjs
import { createHmac, timingSafeEqual } from 'node:crypto';

export function valid(rawBody, header) {
  const want = 'sha256=' + createHmac('sha256', 'YOUR_SIGNING_SECRET').update(rawBody).digest('hex');
  return header?.length === want.length && timingSafeEqual(Buffer.from(header), Buffer.from(want));
}

If it does not work

Discord says the webhook is unknown
It was deleted in Discord. Create a new one and paste it again.
My system gets the same vote twice
We retry until your system answers with a 2xx. Remember the id and ignore it the second time.
Nothing is sent
Only counted votes are sent. Look at the callback log first.

Next

Give your players one place to vote

Your page is live as soon as you create your server. You can connect the rest step by step.