A modern, resilient Discord AI bot built with Discordeno, Bun, PostgreSQL + Drizzle ORM, BullMQ + Redis, and the Vercel AI SDK.
Gateway (Discordeno) → BullMQ Queue → Worker (Vercel AI SDK) → Discord REST
↕
Postgres (Drizzle ORM)
↕
Redis (rate limiter / locks)
| Layer | Tech | Role |
|---|---|---|
| Gateway | Discordeno | Listens for messageCreate, triggers typing indicator, publishes jobs |
| Queue | BullMQ + Redis | Reliable job delivery, 3x exponential-backoff retries |
| Worker | Vercel AI SDK | Multi-provider AI inference with automatic failover |
| Database | PostgreSQL + Drizzle | Guilds, threads, messages with relational schema |
| Cache | Redis (ioredis) | Rate limiting (15/min/user), concurrency locks per channel+user |
| Scheduling | croner | 2-minute summary generation for context window management |
# 1. Install dependencies
bun install
# 2. Copy & edit config
cp config.example.yaml config.yaml
nano config.yaml
# 3. Start Postgres & Redis (or use your own)
docker compose up -d postgres redis
# 4. Push DB schema
bun run db:push
# 5. Run the bot
bun run devAll configuration lives in config.yaml (gitignored). See config.example.yaml for the full template.
Key sections:
discord— Bot token, optional webhook for critical errorspostgres/redis— Connection settingsproviders[]— Ordered list of AI providers (tried in sequence; first success wins, all-fail trips a kill-switch)ai— System prompt, max tokens, rate limits, summary cron, auto-titlingfeatures— Toggle subsystems on/off (auto_reply,auto_title,summarization,rate_limiting,concurrency_lock)search— Web search (RAG) configuration
| Provider | Config name | Type |
|---|---|---|
| OpenAI / ChatGPT | openai |
OpenAI-compatible |
| OpenRouter | openrouter |
OpenAI-compatible |
| HuggingFace | huggingface |
OpenAI-compatible |
| Anthropic / Claude | anthropic |
Anthropic SDK |
| Google / Gemini | gemini |
Google Generative AI SDK |
| Any OpenAI-compatible | * |
OpenAI-compatible |
See docs/providers.md for API keys, free tiers, and model recommendations.
| Platform | Guide |
|---|---|
| Docker Compose | compose.yaml — docker compose up -d |
| Coolify | docs/coolify.md |
| Dokploy | docs/dokploy.md |
| Pterodactyl | docs/pterodactyl.md |
| Local | docs/local.md |
src/
├── index.ts # Entry point
├── config/ # Zod-validated config loader
├── db/ # Postgres connection + Drizzle schema
│ └── schema/ # guilds, threads, messages
├── ai/ # Vercel AI SDK multi-provider wrapper + summary cron
├── gateway/ # Discordeno gateway event listener
├── queue/ # BullMQ publisher + worker
└── lib/ # Redis, rate-limiter, concurrency lock, REST client,
# auto-titling, message chunker
| Command | Description |
|---|---|
bun run dev |
Watch mode development |
bun run start |
Production start |
bun run db:push |
Push Drizzle schema to Postgres |
bun run db:generate |
Generate Drizzle migrations |
bun run db:studio |
Open Drizzle Studio |
bun run lint |
TypeScript type-check |