A production-ready Discord.js framework with advanced features for building scalable Discord bots. Cordium extends Discord.js 14.19 with hot-reload capabilities, structured logging, REST API endpoints, dual-mode deployment, and enhanced prototypes.
Developed by Pupariaa in collaboration with @lakazatong
Cordium supports two operational modes to fit different needs:
- Database: SQLite (local file)
- Cache: RAM (volatile, lost on restart)
- Best for: Development, testing, small servers
- Setup: Zero external dependencies
- Performance: Good
- Database: MySQL/MariaDB (remote server)
- Cache: Redis (persistent)
- Best for: Production, large servers
- Setup: Requires MySQL and Redis servers
- Performance: Excellent
Both modes provide identical functionality - only performance and persistence differ.
- Hot-Reload Development - Commands, events, and endpoints automatically reload on file changes during development without restarting the bot
- Dual-Mode Architecture - Choose between Standalone (SQLite + RAM) or Component (MySQL + Redis) deployment
- Advanced Logging - Structured console reporting with file context, line numbers, function names, and customizable formatting via
extend-console - REST API Integration - Built-in Express server for creating HTTP endpoints alongside Discord commands
- Web Dashboard - Modern web interface for configuration, monitoring, and management
- Configuration Management - Environment-based configuration with validation, type checking, and automatic hot-reload
- Extended Prototypes - Enhanced Discord.js classes with utility methods for Guild, Channel, Member, and more
- CommandsManager - Automatic command registration, deployment, and lifecycle management with button interaction support
- EventsManager - Event listener registration with detailed logging and change tracking for Discord events
- EndpointsManager - RESTful API endpoint management with public/private routing
- AttachmentsManager - File upload and attachment indexing system
- MessagesCache - Smart message caching with Redis or RAM fallback
- EventsDatabase - Automatic event recording and analytics with SQLite or MySQL
- Server Overview - Real-time statistics and activity graphs
- Channel Management - View and manage all server channels
- Role Management - Monitor roles and permissions
- Member Tracking - View all members including departed ones
- Message Cache - Browse cached messages with search
- Configuration - Live settings management
- Modern UI - Dark/light theme, responsive design, custom Cordium branding
- Comprehensive Event Coverage - Pre-structured handlers for 60+ Discord events organized by category
- Global Path System - Automatic path resolution for all internal modules
- Error Handling - Centralized error reporting with stack trace formatting
- Graceful Shutdown - SIGINT handler with cleanup subscriber system
- CLI Tools - Command-line utilities for project initialization and management
- Setup Wizard - Interactive configuration with mode selection and progress persistence
npm installCordium includes an interactive setup wizard that launches automatically on first run:
npm startThis will:
- Launch the Setup Wizard at
http://localhost:3001 - Guide you through mode selection (Standalone or Component)
- Configure Discord bot credentials
- Set up database and cache (Component mode)
- Create all necessary tables automatically
See QUICKSTART.md for detailed instructions.
npm start # Auto-detect: setup wizard or bot
npm run config # Force launch configuration panel
npm run bot # Force launch bot (if configured)
npm run prod # Production modeCordium/
├── config/
│ ├── cli/ # Command-line tools
│ ├── config.json # JSON configuration
│ └── config.env # Environment variables
├── configurator/ # Web configuration panel
│ ├── public/ # Frontend assets
│ │ ├── pages/ # HTML page templates
│ │ ├── index.html # Main UI
│ │ ├── app.js # Frontend logic
│ │ └── style.css # Dashboard styling
│ └── server.js # Configuration API server
├── internals/ # Core framework files
│ ├── prototypes/ # Discord.js class extensions
│ ├── CommandsManager.js
│ ├── EventsManager.js
│ ├── EndpointsManager.js
│ ├── EventsDatabase.js # Event recording system
│ ├── MessagesCache.js # Message caching system
│ ├── ConfigManager.js
│ ├── FilesManager.js
│ └── Utils.js
├── src/
│ ├── commands/ # Slash commands
│ ├── events/ # Discord event handlers
│ │ ├── AutoModeration/
│ │ ├── Channel/
│ │ ├── Guild/
│ │ ├── Message/
│ │ ├── Thread/
│ │ └── ...
│ ├── endpoints/ # API endpoints
│ │ ├── public/ # Publicly accessible
│ │ └── private/ # Authentication required
│ ├── config/ # User configuration
│ ├── sandbox/ # Code testing area
│ ├── cordium.sqlite # SQLite database (Standalone mode)
│ └── index.js # User entry point
├── start.js # Entry point with auto-detection
└── index.js # Framework entry point
Commands are automatically loaded from src/commands/. Each command exports a Discord.js SlashCommandBuilder and an execute function:
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('example')
.setDescription('Example command'),
async execute(interaction) {
await interaction.reply('Hello from Cordium!');
},
buttons: {}
};Events are organized by category in src/events/. Set listen: true to enable an event handler:
module.exports = {
listen: true,
report: true,
callback: async function (message) {
if (global.messagesCache) {
await global.messagesCache.addMessage(message);
}
}
};The framework provides automatic logging for all event changes with before/after comparisons.
Endpoints support GET and POST methods with automatic routing:
module.exports = {
type: 'private',
name: 'get_data',
method: 'GET',
callback: async function (req, res) {
const result = await someAsyncOperation();
res.json({ success: true, data: result });
}
};Access endpoints at http://localhost:8080/private/get_data or http://localhost:8080/public/endpoint_name.
Cordium extends Discord.js classes with utility methods:
const allAuditLogs = await guild.fetchAllAuditLogs();
const latestLog = await guild.latestAuditLog();
const channelName = textChannel.nameWithParents();
const member = await textChannel.fetchMember(userId);client_token=your_bot_token
client_id=your_client_id
discord_guild_id=your_guild_id
db_type=sqlite
db_path=./src/cordium.sqliteclient_token=your_bot_token
client_id=your_client_id
discord_guild_id=your_guild_id
db_type=mysql
db_host=localhost
db_port=3306
db_name=cordium_events
db_user=cordium
db_pass=your_password
redis_host=localhost
redis_port=6379
redis_password=
redis_db=0The framework uses extend-console for structured logging with three report levels:
console.report()- Info level logs with cyan highlightingconsole.reportWarn()- Warning level logs with yellow highlightingconsole.reportError()- Error level logs with red highlighting and stack traces
All logs include timestamp, file location, line number, and function context.
In development mode, the framework watches for file changes and:
- Unloads the module from Node.js require cache
- Reloads the file and validates its structure
- Re-registers commands/events/endpoints
- Logs the reload operation
This enables rapid development without bot restarts.
The framework establishes a global context accessible throughout your code:
global.client- Discord.js Client instanceglobal.guild- Main guild objectglobal.channels- Channel management systemglobal.commandsManager- Command systemglobal.eventsManager- Event systemglobal.endpointsManager- API systemglobal.eventsDatabase- Events database (SQLite or MySQL)global.messagesCache- Messages cache (RAM or Redis)- Path helpers:
global.commandsFolder,global.eventsFolder, etc.
EventsDatabase automatically records all Discord activity:
- Messages (create, update, delete)
- Members (join, leave, update)
- Roles (create, update, delete)
- Voice states (join, leave, mute, deafen)
- Reactions, invites, emojis, and more
All tables are created automatically on first run. Works identically with SQLite or MySQL.
MessagesCache provides fast access to recent messages:
Component Mode (Redis):
- Unlimited storage capacity
- Persistent across restarts
- Fast queries and searches
- Priority message system
Standalone Mode (RAM):
- Up to 10,000 messages in memory
- Lost on bot restart
- Automatic reload from Discord on startup
- Same API as Redis mode
Currently compatible with Discord.js 14.19.1.
Support for Discord.js 14.22 with its new features is planned for a future release.
discord.js^14.19.1 - Discord API wrappersequelize^6.37.7 - ORM for database managementsqlite3^5.1.7 - SQLite database drivermysql2^3.15.2 - MySQL database driverredis^4.7.1 - Redis clientexpress^5.1.0 - HTTP server frameworkextend-console^7.4.7 - Advanced console loggingchokidar^4.0.3 - File system watchersanitize-filename^1.6.3 - Safe filename handlingspectraget^1.1.0 - HTTP request library
MIT
- Pupariaa - Core development
- @lakazatong - Collaboration and tooling