8041a39dfd5714b747fa81ecfd3a179b5ca6af3c
- Added TourScheduleEngine class for managing user queues in a guild. - Implemented methods for joining, leaving, listing, and clearing queues. - Added functionality to promote users to speaker in a stage channel and send announcements. - Created integration tests for the TourScheduleEngine to verify FIFO behavior and announcement dispatch. test: Add unit tests for ping and sign-up commands - Created tests for ping command to ensure it replies with "Pong!". - Implemented tests for sign-up command to verify queue joining, listing, and permission checks. test: Add integration tests for mileage engine flow - Developed tests to validate mileage awarding, event persistence, and role upgrades based on mileage thresholds. chore: Update TypeScript configuration for ESLint - Added tsconfig.eslint.json for ESLint integration. - Modified tsconfig.json to exclude test files from the main compilation.
Discord Bot for Open Mic Odyssey
A modular Discord bot + admin platform that syncs community engagement between Discord and openmicodyssey.com. The system includes onboarding roles, stage queue management, mileage progression, content syndication, an admin API, and a React admin dashboard.
Core Features
The Call Sheet (Onboarding + Roles)
- Reaction-role onboarding message with emoji-to-role bindings
- Role hierarchy safety checks before assignment/removal
- Optional onboarding completion role and welcome-channel message
The Tour Schedule (Stage Queue)
/sign-upsubcommands:join,leave,list,next,clear- FIFO queue per guild
- Optional stage-speaker promotion and queue announcement dispatch
The Dailies (Content Syndication)
- Adapter-based polling pipeline
- YouTube RSS adapter implemented
- Discord webhook dispatch with duplicate suppression
Mileage Engine
- PostgreSQL-backed mileage event/user persistence
- Configurable event scoring
- Role-tier upgrades on threshold milestones
- Retry behavior for transient write failures
Admin API + Dashboard
- Express Admin API for config, queue, stats, OAuth bridge, configuration DB
- React/Vite dashboard for OAuth login + analytics views
OAuth2 Bridge
- Discord OAuth2 code exchange to user profile
- Ephemeral session issuance
- Optional sync callback to openmicodyssey.com backend
Configuration Database
bot_settings,content_schedules,engagement_statstables- Admin CRUD endpoints for settings/schedules
- Engagement snapshot persistence from runtime events
Implemented Modules
src/bot.ts: gateway client lifecycle, command dispatch, service wiringsrc/call-sheet.ts: reaction role onboarding and role hierarchy guardssrc/tour-schedule.ts: FIFO queue, stage speaker promotion, announcementssrc/mileage.ts: mileage persistence, scoring, role-upgrade triggerssrc/dailies/*: adapter/poller/webhook syndication pipelinesrc/admin-api.ts: operational and configuration endpointssrc/oauth-bridge.ts: Discord code exchange + openmic session syncsrc/configuration-database.ts: bot settings, schedules, engagement snapshotsadmin-dashboard/src/*: admin SPA, OAuth callback flow, analytics views
Architecture Documentation (arc42)
This project uses the arc42 template. Chapters are in docs/.
Architecture & Tech Stack
| Layer | Choice |
|---|---|
| Runtime | Node.js + TypeScript |
| Discord SDK | discord.js |
| Database | PostgreSQL |
| Admin API | Express |
| Admin Dashboard | React + Vite |
| Auth | Discord OAuth2 |
| Hosting | Coolify + Nixpacks |
Getting Started
Prerequisites
- Node.js 22+
- npm 10+
- Discord Developer Application (bot token + OAuth2 app)
- PostgreSQL instance
Installation
- Clone repository:
git clone https://git.allucanget.biz/allucanget/omo-bot.git
cd omo-bot
- Install root dependencies:
npm install
- Configure bootstrap environment variables (
.envfrom.env.example):
DATABASE_URL=postgres://...
CONFIG_DB_ENABLED=true
DISCORD_GUILD_ID=... # optional seed scope
- Register slash commands:
npm run register:commands
- Run bot in development:
npm run dev
- Build and run production bundle:
npm run build
npm start
Admin Dashboard
cd admin-dashboard
npm install
npm run dev
Dashboard environment template: admin-dashboard/.env.example.
Validation Commands
npm run lint
npm run build
npm run test
Database Setup Commands
DATABASE_URL is required for each command.
npm run db:migrate
npm run db:seed
npm run db:setup
db:migrate: applies schema migrations tracked inschema_migrationsdb:seed: inserts initial config values from environment intobot_settingswhen missingdb:setup: runs migrate then seed
Runtime Config Source
Runtime reads configuration keys from bot_settings table first, then falls back to environment values.
- Global scope:
guild_id = __global__ - Guild override scope:
guild_id = DISCORD_GUILD_ID - Key names match previous env variable names (examples:
DISCORD_TOKEN,DISCORD_CLIENT_ID,ADMIN_API_TOKEN)
Recommended flow:
- Set bootstrap env (
DATABASE_URL, optionalDISCORD_GUILD_ID). - Run
npm run db:migrate. - Run
npm run db:seedonce while legacy env vars are still present. - Remove legacy runtime vars from
.envafter confirmingbot_settingscontains required keys.
Dashboard quality check:
cd admin-dashboard
npm run lint
npm run build
Admin API Endpoints
GET /healthGET /admin/configGET /admin/stats?guildId=...GET /admin/schedule?guildId=...POST /admin/schedule/clearPOST /admin/oauth/discord/exchangeGET /admin/oauth/session/:sessionIdGET /admin/db/settings?guildId=...PUT /admin/db/settingsGET /admin/db/schedules?guildId=...PUT /admin/db/schedulesDELETE /admin/db/schedules/:guildId/:scheduleKeyGET /admin/db/engagement/latest?guildId=...
CI/CD (Gitea Actions)
Pipeline file: .gitea/workflows/ci-cd.yml
Flow:
- bot checks:
npm ci -> npm run lint -> npm run build -> npm run test - dashboard checks:
admin-dashboard/npm ci -> npm run lint -> npm run build - deploy: on push to
main, trigger Coolify deploy webhook
Required Gitea secrets:
COOLIFY_DEPLOY_HOOK_URL(required)COOLIFY_DEPLOY_TOKEN(optional bearer token)
Contributing
Internal development only. See CONTRIBUTING.md.
Description
Languages
TypeScript
92%
CSS
6.5%
JavaScript
1.2%
HTML
0.3%