A modular Discord bot rebuilt from the ground up with a clean architecture, ES modules, and a dual-database backend (SQLite for dev, Supabase for prod).
- Slash commands — auto-discovered from
src/commands/ - Cogs — feature modules auto-loaded from
src/cogs/(AI, Music, Moderation, Economy, Leveling, Social, Utility, Server Mgmt, Vote) - Dual database — SQLite (dev) via
better-sqlite3, Supabase (prod) via@supabase/supabase-js, behind a unified interface - AI integration — Gemini, Groq, DeepSeek providers
- Music — Lavalink v4 + Shoukaku
- Logging — Winston with daily rotating log files
- Express API — REST API for the web dashboard (port 3005, CORS to
cipher-dc.vercel.app) - Robust error handling — unhandled rejections/exceptions logged, never crash the process
# 1. Install dependencies
npm install
# 2. Configure environment
cp .env.example .env
# Edit .env and fill in DISCORD_TOKEN, AI keys, etc.
# 3. Start the bot
npm start
# 4. (Optional) Dev mode with auto-reload
npm run devPlace a Lavalink v4 jar in the lavalink/ directory and run:
cd lavalink
java -jar Lavalink.jarThe config (lavalink/application.yml) is pre-configured with password sonata_cipher_bot_2026 on port 2333.
src/
├── index.js # Entry point — boots client, db, error handler
├── config/index.js # Env loading + validation
├── core/
│ ├── CommandHandler.js # Auto-discovers slash commands
│ ├── EventHandler.js # Event listener registration
│ ├── CogLoader.js # Auto-loads feature cogs
│ └── ErrorHandler.js # Global process error handlers
├── database/
│ ├── index.js # Unified db interface (SQLite/Supabase)
│ ├── schema.js # 12 table definitions
│ └── migrations.js # CREATE TABLE IF NOT EXISTS runner
├── services/ # Service modules (AI, music, etc.)
├── cogs/ # Feature cogs (auto-loaded)
├── commands/ # Slash commands (auto-discovered)
├── utils/
│ ├── logger.js # Winston logger (console + rotate file)
│ ├── embeds.js # EmbedBuilder factory
│ ├── permissions.js # Permission helpers
│ └── cooldowns.js # Per-user command cooldowns
└── api/server.js # Express REST API (started in HD2)
12 tables auto-created on first boot:
| Table | Purpose |
|---|---|
guilds |
Per-guild settings & feature flags |
users |
XP, level, economy balance, badges |
warnings |
Moderation warnings |
shop_items |
Guild shop items |
inventory |
User purchases |
tickets |
Support tickets |
giveaways |
Active/ended giveaways |
vote_history |
Top.gg / bot listing votes |
reminders |
User reminders |
reaction_roles |
Reaction → role mappings |
starboard_messages |
Starred messages |
music_history |
Played track log |
Dev uses SQLite at data/cipher.db. Prod uses Supabase (auto-detected when SUPABASE_URL + SUPABASE_SERVICE_ROLE_KEY are set).
- Node.js ES Modules (
"type": "module") - Discord.js v14.26.4
- better-sqlite3 / @supabase/supabase-js
- winston + winston-daily-rotate-file
- Express + CORS (API server)
- Shoukaku + Lavalink v4 (music)
- @google/generative-ai / openai (AI providers)
Private project.