Celestine
Celestine (hereinafter the βApplicationβ) is a comprehensive paid moderation bot for Discord servers, built with TypeScript and Discord.js. The Application provides advanced moderation tools, automated security features, leveling systems, birthday celebrations, and comprehensive logging capabilities. It includes a web server for health monitoring and metrics, integrates with MongoDB for data persistence, and features a subscription-based access model.
1. User Documentation
Core Features
Moderation Commands
/ban
- Ban users from the server with optional message pruning and evidence links/unban
- Remove bans from users with logging and notification systems/kick
- Remove users from the server temporarily/mute
- Temporarily restrict user communication with duration controls (minutes, hours, days, weeks)/unmute
- Remove communication restrictions from users/warn
- Issue warnings to users with evidence tracking/note
- Add private moderation notes about users/softban
- Ban and immediately unban to clean up user messages/massban
- Ban multiple users at once using a list of user IDs
Server Management
/lockdown
- Lock text channels to prevent message sending/unlock
- Remove lockdown restrictions from channels/prune
- Bulk delete messages from channels/secure
- Toggle server-wide DM and invite restrictions for new members
Configuration System
/config list
- View current server configuration/config logging
- Set up moderation and event log channels/config invite-link
- Configure invite links sent to kicked users/config appeal-link
- Set ban appeal links for banned users/config roles
- Toggle roles as self-assignable/config join-role
- Set automatic role assignment for new members/config birthday-channel
- Configure birthday celebration channel
User Experience Features
/rank
- View personal level and XP in the server/leaderboard
- Browse server level rankings with pagination/profile
- Customize profile appearance (avatar, colors, background)/role
- Self-assign permitted roles/birthday
- Set birthday for automatic celebrations/level-role
- Configure roles automatically assigned at specific levels
Administrative Tools
/cases
- View specific moderation case details/history
- View comprehensive user moderation history/help
- Get bot information, version details, and support links/ping
- Check bot latency and database connectivity
Context Menu Actions
- Report Message - Right-click context menu to report problematic messages
Automated Features
Leveling System
- Automatic XP gain from message activity with anti-spam cooldowns
- Customizable level roles that auto-assign at specified levels
- Visual profile cards with customizable backgrounds and colors
- Server leaderboards with pagination
Security & Moderation
- Automatic detection and removal of known spam domains
- Automatic muting of compromised accounts posting malicious links
- Comprehensive audit logging for all moderation actions
- Member join/leave tracking with configurable logging
Event Logging
- Message edit/delete tracking with content preservation
- Voice channel activity monitoring
- Member update tracking (nickname, role changes)
- Moderation action logging with evidence and case numbers
Birthday System
- Automatic birthday wishes in designated channels
- Scheduled daily birthday checks
- User-configurable birthday dates with validation
Access Control
- Subscription-based access model ($5/month)
- Permission-based command restrictions
- Moderator role validation for administrative commands
- Granular configuration permissions
This section is for those interacting with a live instance of the Application.
2. Technical Documentation
Architecture Overview
Celestine is built as a modern Discord bot using:
- Runtime: Node.js with TypeScript
- Discord Library: Discord.js v14
- Database: MongoDB with Prisma ORM
- Web Server: Express.js for health endpoints
- Monitoring: Prometheus metrics integration
- Scheduling: Node-schedule for automated tasks
Project Structure
src/βββ commands/ # Slash command implementationsβββ contexts/ # Context menu command handlersβββ events/ # Discord event handlersβ βββ client/ # Bot lifecycle eventsβ βββ guild/ # Server-related eventsβ βββ interaction/ # Command interaction handlingβ βββ member/ # Member join/leave/update eventsβ βββ message/ # Message create/edit/delete eventsβ βββ thread/ # Thread-related eventsβ βββ voice/ # Voice state change eventsβββ interfaces/ # TypeScript type definitionsβββ modules/ # Reusable business logicβ βββ commands/ # Command-specific modulesβ βββ data/ # Database interaction modulesβ βββ events/ # Event processing modulesβ βββ interactions/ # Interaction handling modulesβ βββ modals/ # Modal form handlersβ βββ subcommands/ # Subcommand implementationsβββ server/ # Web server and health endpointsβββ utils/ # Utility functions and helpersβββ config/ # Configuration constantsβββ database/ # Database connection setup
Database Schema
The application uses MongoDB with the following key models:
Core Data Models
cases
- Moderation case tracking with evidence and timestampsconfigs
- Per-server configuration settingslevels
- User XP and level progression datalevelRoles
- Automatic role assignments by levelroles
- Self-assignable role permissionsbirthdays
- User birthday trackingentitlements
- Server subscription managementsecurity
- Server security settings (DM/invite restrictions)
Key Features of Data Layer
- Unique constraints for data integrity
- Indexed queries for performance
- Automatic relationship management
- Soft deletion support for case history
Development Setup
Prerequisites
- Node.js 18+
- MongoDB instance
- Discord Bot Token
- TypeScript compiler
Environment Variables
TOKEN=<discord_bot_token>MONGO_URI=<mongodb_connection_string>DEBUG_HOOK=<discord_webhook_url>DEV_MODE=<boolean>
Build Process
npm install # Install dependenciesnpm run prebuild # Clean build directory and generate Prisma clientnpm run build # Compile TypeScript to JavaScriptnpm start # Run the bot
Development Scripts
npm run lint
- ESLint and Prettier validationnpm run audit
- Dependency and code analysis with Knipnpm run scan
- SonarCloud quality analysis
Web Server Endpoints
The bot includes an Express.js server providing:
Health & Status
GET /
- HTML landing page with bot information and invite linksGET /metrics
- Prometheus metrics endpoint for monitoring
Integration Points
Discord API
- Slash commands and context menus
- Webhook integrations for logging
- Permission validation
- Message content scanning
External Services
- GitHub integration for version tracking
- Prometheus metrics collection
- MongoDB Atlas for cloud database
- 1Password for secrets management
Monitoring & Observability
Logging
- Winston-based structured logging
- Error tracking with unique identifiers
- Debug message routing to Discord webhooks
- Comprehensive audit trails
Metrics
- Prometheus integration for performance monitoring
- Database latency tracking
- Command usage statistics
- Server count and member tracking
Security Considerations
Access Control
- Subscription validation for server access
- Permission-based command restrictions
- Rate limiting through Discord.js built-ins
- Input validation and sanitization
Data Protection
- Encrypted database connections
- Secure environment variable handling
- Minimal data retention policies
- Privacy-conscious logging practices
This section is for those interested in running their own instance of the Application.
3. Legal Documentation
Subscription Model
Celestine operates as a paid service with a $5/month subscription fee per Discord server. This subscription model ensures:
- Sustainable development and maintenance
- Priority support for subscribers
- Regular feature updates and improvements
- Infrastructure costs coverage
Data Handling
The Application processes and stores:
- Discord user IDs and server IDs
- Message content for moderation purposes (temporary)
- User-configured profile information
- Moderation case history and evidence links
- Server configuration preferences
Service Availability
- Best-effort uptime with monitoring systems
- Planned maintenance notifications
- Support through designated Discord server
- Community-driven feedback and feature requests
4. Contributing Documentation
Development Workflow
Code Standards
- TypeScript for type safety
- ESLint and Prettier for code formatting
- Comprehensive error handling with unique error IDs
- JSDoc documentation for public interfaces
Testing Strategy
- Integration testing with Discord API
- Database transaction testing
- Command validation testing
- Performance benchmarking
Pull Request Process
- Fork the repository
- Create feature branch from main
- Implement changes with tests
- Ensure linting and build passes
- Submit PR with detailed description
- Address review feedback
- Merge after approval
Architecture Decisions
- Modular command structure for maintainability
- Event-driven architecture for real-time responses
- Database abstraction through Prisma ORM
- Configuration-driven behavior customization
Extension Points
Adding New Commands
- Create command file in
src/commands/
- Implement Command interface
- Add to command loader
- Update permissions if needed
- Add documentation
Custom Event Handlers
- Create handler in appropriate
src/events/
subdirectory - Implement error handling
- Add to event registration system
- Test with Discord API
Database Schema Changes
- Update Prisma schema
- Generate migration
- Test migration on development database
- Update TypeScript interfaces
- Implement backward compatibility