Public
Discord RPG bot using polls to drive story choices
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

⚔️ Discord RPG Quest Bot

A community-driven RPG game where Discord polls decide the hero's fate! Every hour, a new scenario appears in your Discord channel as a poll. The community votes on what the hero should do, and the winning choice becomes the next action in the story.

How It Works

Rendering mermaid diagram...

Features

  • 🐉 6 unique scenarios with 4 choices each (dragon fights, haunted villages, wizard encounters, bandit ambushes, enchanted rivers, skeleton kings)
  • 🗳️ Native Discord polls — uses Discord's built-in poll feature, not reactions
  • Automatic progression — hourly cron job reads results and advances the story
  • 📊 Character stats — HP, Gold, XP, Level with progression
  • 📜 Adventure log — full history of every round and outcome
  • 🌐 Web dashboard — view game state, start games, and manually trigger actions

Setup

1. Create a Discord Webhook

  • Go to your Discord server → Channel Settings → Integrations → Webhooks
  • Create a webhook and copy the URL

2. Create a Discord Bot (for reading poll results)

  • Go to Discord Developer Portal
  • Create a new application → Bot → copy the token
  • Enable the bot in your server with Read Message History permission

3. Set Environment Variables in Val Town

VariableDescription
DISCORD_WEBHOOK_URLYour channel's webhook URL
DISCORD_BOT_TOKENBot token for reading poll results
DISCORD_CHANNEL_IDThe channel ID where polls are sent

4. Start Playing!

  • Visit the web dashboard and click 🎮 New Game
  • The bot sends a scenario + poll to Discord
  • Your community votes!
  • Every hour, results are checked and the story advances

Architecture

FilePurpose
main.tsHTTP dashboard & API (Hono)
poll-checker.tsHourly cron job to read polls & advance game
game/engine.tsCore game logic
discord/webhook.tsDiscord webhook & API integration
shared/scenarios.tsRPG scenarios and character creation
shared/types.tsTypeScript types
database/migrations.tsSQLite schema
database/queries.tsDatabase operations