Disco Stu - Teal.fm Discord Bot#
This repository contains the Disco Stu Discord bot, supporting services, and shared packages used by the project. The workspace is a monorepo managed with pnpm and TypeScript; each app and package has its own package.json and build/dev scripts.
Repository Structure
apps/: Application code (runtime programs and services)bot/: Discord bot (commands, deploy script)tapper/: Backfill client for Tap serviceweb/: Web server to handle OAuth
packages/: Shared libraries used across appscommon/: Logging and shared utilitiesdatabase/: Database access, Kysely migrations and seed scriptstsconfig/: Shared TypeScript config packages
Apps
-
apps/bot— Discord bot- Entry:
apps/bot/main.ts. - Key files:
apps/bot/commands/*.ts(command handlers),apps/bot/deploy-commands.ts(registers commands with Discord),apps/bot/discord.d.ts(types). - Useful scripts (see apps/bot/package.json):
dev— run bot in watch mode withtsx --watch main.tsdeploy-commands— rundeploy-commands.tsto push slash-command definitions to Discordbuild— compile TypeScript todist/start— run compiled bot fromdist/main.js
- Entry:
-
apps/tapper— Tap client- Entry:
apps/tapper/index.ts. - Purpose: Interact with tap service running at https://tap.xero.systems
- Useful scripts (see apps/tapper/package.json):
dev— runsNODE_ENV=development tsx index.tsstart— run compileddist/index.jsin production
- Entry:
-
apps/web— Web server- Entry:
apps/web/index.ts. - Integrates with AT Protocol APIs and provides OAuth/web endpoints.
- Useful scripts (see apps/web/package.json):
dev—tsx --watch index.tsto run in devbuild— compile TypeScriptstart— run compiled server fromdist/index.js
- Entry:
Packages
-
packages/common— shared utilities and logging- Exports logging helpers and other common utilities used by apps. Build with
pnpm --filter @tealfmbot/common buildor use workspace protocol. - Scripts:
build,build:watch,typecheck(see packages/common/package.json).
- Exports logging helpers and other common utilities used by apps. Build with
-
packages/database— Kysely-based database layer- Contains DB helpers,
migrate.ts,seed.ts, and Kysely codegen support. - Scripts (see packages/database/package.json):
migrate— runkysely migrate latestto apply migrationscodegen— runkysely-codegento regeneratedatabase.d.tsseed— runtsx seed.tsto seed databuild,build:watch,typecheck
- Contains DB helpers,
-
packages/tsconfig— shared TypeScript configs- Provides base tsconfig settings shared by other packages.
Top-level scripts (see package.json)
pnpm bot— start the bot dev script (pnpm --filter bot dev)pnpm tap— start the tapper dev script (pnpm --filter tapper dev)pnpm web— start the web app dev script (pnpm --filter web dev)pnpm build— runpnpm -r buildto build all packages and appspnpm build:watch— run watch builds across the monorepopnpm dev:all— runsdevfor all apps underapps/pnpm typecheck— run TypeScript checks across appspnpm lint— runoxlint(project linter)pnpm format— runoxfmtto format code
Developer workflow
- Install dependencies:
pnpm install(pnpm v10+ recommended) - Develop a single app:
- Bot:
pnpm --filter bot devorpnpm bot - Tapper:
pnpm --filter tapper devorpnpm tap - Web:
pnpm --filter web devorpnpm web
- Bot:
- Develop all apps concurrently:
pnpm dev:all - Build all packages and apps:
pnpm build
Database tasks
- Migrations are managed via Kysely. Run migrations from the
packages/databasepackage:
pnpm --filter @tealfmbot/database migrate
- Regenerate types (codegen):
pnpm --filter @tealfmbot/database codegen
Docker / deployment
Dockerfileanddocker-compose.prod.ymlare included for building and deploying container images.- The repository contains
build-and-publish-images.shto build and publish images (will be a CI thing eventually).
Project tooling
lefthook.ymlconfigures git hooks.oxlintandoxfmtare used for linting and formatting.
Notes & tips
- To deploy Discord commands after changes, run the bot package
deploy-commandsscript:
pnpm --filter bot deploy-commands
Contributing & Quickstart
If you want to contribute or get a local development environment running quickly, follow these steps:
- Clone the repo and install dependencies:
git clone https://tangled.org/dane.is.extraordinarily.cool/tealfmbot
cd tealfmbot
pnpm install
- Start and run database migrations
docker compose -f docker-compose.dev.yml up -d
cd packages/database
pnpm migrate
- Start individual apps in development:
# Bot
pnpm bot
# Tapper
pnpm tap
# Web
pnpm web
- Start all apps concurrently (monorepo dev):
pnpm dev:all
- Build everything:
pnpm build
- Run TypeScript checks and format/lint before opening a PR:
pnpm typecheck
pnpm lint
pnpm format
Please open issues or PRs for new features, and include clear reproduction steps and expected behavior.