Draft bot for Civ VI that uses Discord Activities
This is a deployment guide, check out the Manual to see how the bot works on a high level, or the Guide for a quick start guide for players.
- Bun
- Cloudflare account
- Discord app created in the Discord Developer Portal
cloudflaredlocally for dev
-
Install deps:
bun install
-
Copy the dev env files:
cp cloudflared.dev.example.yml cloudflared.dev.yml cp apps/bot/.dev.vars.example apps/bot/.dev.vars cp apps/activity/.dev.vars.example apps/activity/.dev.vars cp apps/party/.dev.vars.example apps/party/.dev.vars
and fill them in. glhf
-
Apply the local DB schema:
bun run bot:l:migrate
-
Set up Cloudflare Tunnels
Update
cloudflared.dev.ymlwith your domains and create tunnels, also updateapps/activity/vite.config.ts. -
Set these in the Discord Developer Portal:
- Interactions Endpoint URL: your bot tunnel URL
- Activity URL Mapping: your activity tunnel URL
-
Register bot commands in your guild:
bun run bot:register
-
Start the full local stack:
It runs these: 1. Bot, 2. Activity, 3. Partyserver, 4. Tunnels
bun run dev:new
This will rebuild the activity app, use
bun run devto skip that.
bun run dev:new
bun run dev
bun run dev:live
bun run bot:l:migrate
bun run bot:dev
bun run a:dev:new
bun run a:dev
bun run a:dev:live
bun run party:dev
bun run tunnel
bun run bot:kv:localLeaderboard:
curl.exe "http://127.0.0.1:8787/cdn-cgi/handler/scheduled?cron=%2A%2F2+%2A+%2A+%2A+%2A"Inactivity cleanup:
curl.exe "http://127.0.0.1:8787/cdn-cgi/handler/scheduled?cron=0+%2A+%2A+%2A+%2A"-
Provision Cloudflare resources once:
bun run bot:d1:create bun run bot:kv:create
-
Copy the production env files:
cp apps/bot/.prod.secrets.example apps/bot/.prod.secrets cp apps/activity/.prod.secrets.example apps/activity/.prod.secrets cp apps/activity/.prod.vars.example apps/activity/.prod.vars cp apps/party/.prod.secrets.example apps/party/.prod.secrets
fill them in again :)
-
Update Cloudflare config to use your own account, URLs, and routes:
apps/bot/wrangler.jsoncapps/activity/wrangler.jsoncapps/party/wrangler.jsonc
At minimum:
- set
BOT_HOSTto your deployed bot worker URL - set
PARTY_HOSTto your deployed party worker URL - set
VITE_ACTIVITY_HOSTto your deployed activity host without protocol - replace account IDs, database IDs, KV IDs, and route/domain values that still point at a different account
-
Upload secrets:
bun run bot:secrets:prod bun run a:secrets:prod bun run party:secrets:prod
-
In the Discord Developer Portal:
- Interactions Endpoint URL: your bot worker URL
- Activity URL Mapping: your activity worker URL
-
Deploy:
bun run deploy:prod
That runs the remote DB migration and deploys bot, activity, and party.
-
Register slash commands:
bun run bot:register:prod
Or do deploy + register in one step:
bun run deploy:prod:full