# Live Siege Discord bot (/docs/api/guides/discord-bot)

Post verified Strave match updates, results, and live playday scores to Discord channels.

This guide sets up a Discord bot that receives Strave webhook deliveries and
reads tournament standings from Public API v2.

## 1. Scaffold the project [#1-scaffold-the-project]

Use `@strave/cli` to generate either a plain TypeScript or Effect v4 starter:

```bash
bunx @strave/cli init discord-bot my-siege-bot
# Or with Effect v4:
bunx @strave/cli init discord-bot-effect my-siege-bot
```

## 2. Verify incoming webhooks [#2-verify-incoming-webhooks]

Every delivery carries `strave-webhook-id`, `strave-webhook-timestamp`, and
`strave-webhook-signature`. Verify the HMAC-SHA256 signature on the raw request
body before posting to Discord:

```ts
import { createStraveWebhookHandler } from "@strave/sdk/webhooks";

export const POST = createStraveWebhookHandler({
	secret: process.env.STRAVE_WEBHOOK_SECRET!,
	onEvent: async (event) => {
		if (event.type === "match.result_confirmed") {
			await postMatchSummaryToDiscord(
				event.data.eventId,
				event.data.resourceId,
			);
		}
	},
});
```

## 3. Test locally with `@strave/cli` [#3-test-locally-with-stravecli]

Send signed Sandbox test deliveries to your local handler:

```bash
bunx @strave/cli trigger match.result_confirmed \
	--url http://127.0.0.1:3000/api/webhooks/strave
```