🎉 Tickety V3 has now been released! Read more →
APIHTTP EventsGiveaway Events

End

Triggered when a giveaway ends and winners are drawn

Event Type

"giveaway.end"

Description

This event is triggered once a giveaway has ended and the winners have been announced. It is sent after the giveaway is committed as ended, so it is never sent twice for the same giveaway, and never for an end that failed and will be retried.

This is the only event that carries the full participant list.

Payload Structure

Prop

Type

winners can be shorter than winnersCount, or empty, when fewer members entered than there were prizes to hand out. participants is a full list, so a giveaway with thousands of entries produces a large payload. Make sure your endpoint accepts it.

Example Payload

{
  "type": "giveaway.end",
  "payload": {
    "giveawayId": "hT7pLm2Qa9",
    "prize": "Nitro Classic",
    "channelId": "1140972530400776294",
    "messageId": "1141002938471829504",
    "messageUrl": "https://discord.com/channels/1140972530400776290/1140972530400776294/1141002938471829504",
    "winnersCount": 2,
    "creatorId": "280158289667555328",
    "hostedBy": "280158289667555328",
    "endedAt": "2024-01-19T15:30:00.000Z",
    "winners": ["713115896805064856", "280158289667555328"],
    "participants": [
      "713115896805064856",
      "280158289667555328",
      "1140972530400776299"
    ],
    "participantsCount": 3
  }
}

Example Usage

app.post('/webhook', (req, res) => {
  const { type, payload } = req.body;

  if (type === 'giveaway.end') {
    console.log(`Giveaway ended: ${payload.prize}`);
    console.log(`Winners: ${payload.winners.join(', ')}`);

    // Hand out the prize in your own system
    for (const userId of payload.winners) {
      await grantReward(userId, payload.prize);
    }

    // Keep the entry list for your own records
    await storeParticipants(payload.giveawayId, payload.participants);
  }

  res.status(200).send('OK');
});

Use Cases

  • Hand out a reward automatically to every winner
  • Store the full entry list for auditing or for a public results page
  • Post the result to another platform
  • Measure how many members a giveaway actually reached

On this page