Add SQLite database for dynamic guild management

Features:
- SQLite database with better-sqlite3 for guild configurations
- Auto-registration when bot joins new guilds with welcome messages
- Soft delete system preserves settings when bot is removed
- Dynamic configuration via /config slash command with subcommands
- Automatic migration from config.json to database on first run
- Support for scheduled events with timezone preservation

Technical Implementation:
- Node.js 20 for better SQLite compatibility in Docker
- Full Debian base image with npm for reliable native module compilation
- Database persistence via Docker volume (./data)
- Hybrid configuration system (database primary, file fallback)
- JSON storage for complex schedule objects with timezone support

Database Schema:
- guilds table with soft delete (is_active flag)
- scheduled_events table with JSON schedule storage
- bot_config table for global settings
- Auto-initialization and seeding from existing config

Admin Features:
- /config show - View current server settings
- /config subcommands - Update prefix, volume, features, etc.
- Administrator permissions required for configuration changes
- Graceful handling of missing or malformed data

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Chris Ham
2025-08-16 14:02:27 -07:00
parent 9661ba92d5
commit d74aebfda7
12 changed files with 1157 additions and 75 deletions

View File

@@ -4,27 +4,29 @@
"description": "",
"main": "src/index.js",
"dependencies": {
"axios": "^1.11.0",
"discord.js": "^14.21.0",
"@discordjs/voice": "^0.18.0",
"@discordjs/opus": "^0.9.0",
"opusscript": "^0.1.1",
"@discordjs/voice": "^0.18.0",
"axios": "^1.11.0",
"better-sqlite3": "^11.10.0",
"discord.js": "^14.21.0",
"ffmpeg-static": "^5.2.0",
"node-schedule": "^2.1.1",
"opusscript": "^0.1.1",
"sodium-native": "^4.3.3"
},
"devDependencies": {
"@types/node": "^22.0.0",
"nodemon": "^3.1.9"
"@types/node": "^22.17.2",
"nodemon": "^3.1.10"
},
"scripts": {
"start": "node src/index.js",
"dev": "nodemon src/index.js",
"up": "docker compose up -d",
"down": "docker compose down",
"start": "docker compose up -d",
"start:logs": "pnpm start && pnpm logs",
"stop": "docker compose down",
"build": "docker compose build",
"restart": "docker compose restart",
"logs": "docker compose logs -f",
"boom": "pnpm stop && pnpm build && pnpm start",
"image:build": "docker build -t ghbot:${VERSION:-latest} .",
"image:run": "docker run -d --name ghbot --restart always ghbot:${VERSION:-latest}"
},