Mention-first Discord bot with URL-aware prompt enrichment, image generation/editing, and a MariaDB-backed log viewer.
| If you want to... | Read this |
|---|---|
| Understand the whole system quickly | docs/architecture.md |
| See the current command surface | docs/commands.md |
| Configure env vars correctly | docs/configuration.md |
| Run the project locally or in Docker | docs/development.md |
| Understand the docs set at a glance | docs/README.md |
| Area | Purpose |
|---|---|
src/ |
Python Discord bot, services, startup wiring, downloader utilities, DB logging |
tests/ |
Python unit/integration-style coverage for the bot and utilities |
log-viewer/backend/ |
Node/TypeScript API + Socket.IO service for reading logs |
log-viewer/frontend/ |
React/Vite UI for browsing API and pipeline logs |
docs/ |
Architecture, commands, configuration, development, deployment, and troubleshooting docs |
| Capability | Current behavior |
|---|---|
| Chat | Users mention the bot in Discord; there is no current /chat command |
| Context building | Recent channel history, reply context, embeds, and attachments are folded into the prompt |
| URL enrichment | The bot can inject transcripts/context from YouTube, TikTok, Twitter/X, Facebook, and generic articles |
| Images | Slash commands support image generation and image editing through RunpodService |
| Logging | API requests and pipeline steps are written to MariaDB |
| Observability | The log viewer backend/frontend read and stream those logs |
Use this if you mainly want to work on the Python bot.
cp env.example .env
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
.venv/bin/pip install -r test_requirements.txt
.venv/bin/python main.pyUse this if you want bot + MariaDB + log viewer together.
cp .env.development.example .env.development
docker compose --env-file .env.development up --buildDefault dev ports:
| Service | Port |
|---|---|
| MariaDB | 3306 |
| Log viewer backend | 3001 |
| Log viewer frontend | 5173 |
| Group | Commands |
|---|---|
| General | /help, /model, /restart |
| Prompting | /systemprompt set, /systemprompt view, /systemprompt reset |
| Images | /draw, /drawmodel, /edit, /editmodel |
| Interjections | /interject set, /interject view, /interject reset, /interject count |
| Deathwatch | /death set, /death view, /death reset |
Chat itself remains mention-based.
| Variable | Required | Why |
|---|---|---|
DISCORD_BOT_TOKEN |
Yes | Connects the bot to Discord |
OPENROUTER_API_KEY |
Yes | Powers text-model completions |
RUNPOD_IO_API_KEY |
If using image commands | Powers draw/edit requests |
| Variable | Required when | Why |
|---|---|---|
RAPIDAPI_KEY |
Using Twitter/X enrichment | Fetches tweet/context data |
GROQ_API_KEY |
Using TikTok/Facebook/Twitter-video transcription | Runs audio transcription |
TRANSCRIPT_PROXY |
Optional | Helps when direct transcript/media fetches fail |
| Variable | Default | Why |
|---|---|---|
DB_HOST |
127.0.0.1 |
MariaDB host |
DB_PORT |
3306 |
MariaDB port |
DB_USER |
cmwgpt_user |
MariaDB user |
DB_PASSWORD |
empty | MariaDB password |
DB_NAME |
cmwgpt |
Database name |
For the full reference, see docs/configuration.md.
main.py boots src/startup.py, which wires services like StateService, QueueService, OpenAIService, RunpodService, InterjectService, DeathService, and MentionHandler into DiscordBotClient. Mention replies are assembled by src/bot/handlers/mention.py, enriched through src/utils/downloader_utils.py, sent to OpenRouter for text output, and logged into MariaDB. The log-viewer backend and frontend then query and stream those logs for inspection.
For diagrams and a deeper walkthrough, see docs/architecture.md.
| What you want | Command |
|---|---|
| Default Python suite | make test |
| Verbose Python suite | make test-verbose |
| Coverage run | make test-coverage |
| Direct pytest | .venv/bin/python -m pytest |
| Frontend tests | cd log-viewer/frontend && npm run test |
More detail: tests/README.md and log-viewer/frontend/README.md.
- Prefer
make run-directfor local bot development. make runusesstart.sh, and the current wrapper assumes avenv/path while the Makefile creates.venv/by default./restarttriggers the restart handler, which saves state, performs agit pull, and exits with code42.
The docs are meant to be read as a small system, not as isolated files:
docs/README.md- docs indexdocs/architecture.md- diagrams + component map + request flowdocs/commands.md- current command surfacedocs/configuration.md- env vars and defaultsdocs/development.md- local and Docker workflowsdocs/deployment.md- runtime/deployment notesdocs/mariadb_setup.md- schema and DB setupdocs/troubleshooting.md- common failure modes