A comprehensive Discord bot written in TypeScript with MongoDB and Redis integration. Features advanced moderation, welcome systems, sticky messages, auto-reactions, suggestion system, and fun commands. Built with strict TypeScript for enhanced type safety and reliability.
- Customizable welcome messages for new members
- Rich embeds with variables like
{user},{server},{memberCount} - Channel-specific configuration
- MongoDB persistence
- Auto-reposting messages when other messages are sent
- Channel-specific sticky messages
- Easy management via slash commands
- Database persistence
- Automatic emoji reactions for specific channels
- Support for custom server emojis and Unicode
- Pattern-based reactions
- Redis caching for performance
- Automatic message responses to keywords/phrases
- Case-sensitive and case-insensitive matching
- Exact match or contains mode
- Channel-specific configuration
- Administrator-controlled with Redis caching
- User suggestion submission via slash commands
- Admin approval/denial workflow
- Status tracking with reasons
- Community voting with custom emojis
- Warning System: User warnings with escalation rules
- Auto-Moderation: Spam protection, word filtering, raid protection
- Moderation Tools: Ban, kick, mute, timeout with comprehensive logging
- Case Management: Detailed moderation logs and case tracking
- Permission Control: Role-based command access and safety checks
- Interactive games (Rock-Paper-Scissors, 8-ball, dice)
- Random content (jokes, facts, coin flips)
- Server and user information commands
- Ping and status commands
- Bun v1.0+ (Latest recommended)
- Node.js 18+ (Alternative runtime)
- MongoDB 5.0+ (Database)
- Redis 6.0+ (Optional, for caching and performance)
- Discord Bot Token from Discord Developer Portal
-
Clone the repository
git clone https://github.com/Powenwen/Chibi-bot.git cd Chibi-bot -
Install dependencies
bun install
-
Configure environment
cp .env.example .env # Edit .env with your Discord bot token and database settings -
Validate setup
# Validate configuration and dependencies bun run validate-config # Check database connectivity bun run health-check
-
Start the bot
# Development mode (with hot reload) bun run dev # Production mode bun run start # Full validation + start bun run full-check
Create a .env file with the following settings:
# Discord Bot Configuration
TOKEN=your_discord_bot_token_here
CLIENT_ID=your_discord_application_id_here
GUILD_ID=your_discord_guild_id_here
# Database Configuration
MONGO_URI=mongodb://localhost:27017/chibibase
MONGO_DB_NAME=chibibase
# Redis Configuration (optional)
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
# Development Settings
NODE_ENV=development
PREFIX=c!
# Feature Flags
ENABLE_WELCOME_SYSTEM=true
ENABLE_STICKY_MESSAGES=true
ENABLE_AUTO_REACTIONS=true
ENABLE_HEALTH_CHECKS=true
# Cache and Monitoring
MESSAGE_CACHE_TTL=3600
USER_DATA_CACHE_TTL=7200
ERROR_THRESHOLD=50
HEALTH_CHECK_INTERVAL=300000
# Command Registration
USE_GUILD_COMMANDS=true
TARGET_GUILD_ID=your_test_guild_id_here
FORCE_REGISTER_COMMANDS=falsebun run dev # Start with hot reload
bun run start # Production start
bun run build # Build for production
bun run build:watch # Build with watch mode
bun run clean # Clean build artifactsbun run type-check # Main TypeScript checking
bun run type-check:scripts # Scripts TypeScript checking
bun run validate # Full TypeScript validation
bun run validate-config # Configuration validation
bun run health-check # Database & services health check
bun run full-check # Complete validation + health + startbun run version:patch # Bump patch version (3.1.2 → 3.1.3)
bun run version:minor # Bump minor version (3.1.2 → 3.2.0)
bun run version:major # Bump major version (3.1.2 → 4.0.0)
bun run readme:update-version # Update README version badgebun run test # Run test suite
bun run test:watch # Run tests in watch mode
bun run test:coverage # Run tests with coveragesrc/
├── commands/ # Slash commands by category
│ ├── auto-reaction-system/
│ ├── auto-responder-system/
│ ├── dev/
│ ├── fun/
│ ├── info/
│ ├── moderation/
│ ├── sticky-message/
│ ├── suggestion-system/
│ └── welcome-system/
├── events/ # Discord.js event handlers
│ ├── client/
│ ├── guild/
│ └── interaction/
├── features/ # Core feature implementations
├── models/ # MongoDB schemas
├── structures/ # Bot classes and handlers
├── utils/ # Utility functions
└── index.ts # Main entry point
scripts/ # Development scripts
assets/ # Bot images and icons
- Strict Mode: Full TypeScript strict mode enabled for maximum type safety
- Path Mapping: Clean imports with
@/aliases for better organization - Separate Configs: Dedicated tsconfig for scripts and main application
- Build Target: Optimized for Bun runtime with ES modules
- Hot Reload: Instant restart on file changes during development
- Health Monitoring: Built-in health checks for databases and services
- Configuration Validation: Runtime validation of environment variables
- Version Management: Automated version bumping with git integration
- Error Handling: Comprehensive error handling and logging system
- Redis Caching: Optional Redis integration for improved performance
- Connection Pooling: Efficient MongoDB connection management
- Event Optimization: Optimized Discord.js event handling
- Memory Management: Careful resource management and cleanup
The bot automatically creates these MongoDB collections:
welcomesystems- Welcome message configurations per serverstickymessages- Sticky message data and settingsautoreactions- Auto-reaction channel configurationsautoresponders- Auto-responder trigger and response configurationsauthorizedusers- Authorized user permissions and roles
suggestions- User-submitted suggestions with votingsuggestionchannels- Suggestion channel configurations per server
moderationlogs- Detailed moderation action logsmoderations- Active moderation cases and infractionsautomoderations- Auto-moderation configuration per serverwarningescalations- Warning escalation rules and thresholds
All collections include proper indexing for optimal query performance and automatic cleanup of expired data where applicable.
TypeScript Errors
# Fix type checking issues
bun run type-check
bun run validateDatabase Connection Issues
# Check database connectivity
bun run health-check
bun run validate-configEnvironment Configuration
# Ensure .env file exists and is properly configured
cp .env.example .env
# Edit .env with your actual valuesBot Permissions
- Ensure bot has necessary permissions in Discord server
- Check that bot token is valid and not expired
- Verify CLIENT_ID and GUILD_ID are correct
Performance Issues
- Enable Redis caching for better performance
- Check MongoDB connection and indexing
- Monitor bot memory usage and restart if needed
# Enable verbose logging
NODE_ENV=development bun run dev
# Check specific component health
bun run health-checkWe welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Install dependencies (
bun install) - Make your changes with proper TypeScript types
- Run validation (
bun run validate) - Test your changes thoroughly
- Commit with conventional commit format (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request with detailed description
- Follow TypeScript strict mode requirements
- Use meaningful variable and function names
- Add JSDoc comments for public methods
- Ensure all type checks pass
- Test edge cases and error conditions
feat:- New featuresfix:- Bug fixesdocs:- Documentation updatesstyle:- Code style changesrefactor:- Code refactoringtest:- Adding testschore:- Maintenance tasks
This project is licensed under the ISC License - see the LICENSE file for details.
- 🐛 Bug Reports: GitHub Issues
- 💡 Feature Requests: GitHub Discussions
- 📚 Documentation: This README and inline code documentation
- 💬 Discord Support: Join our server
Made with ❤️ for the Discord community
Empowering Discord servers with comprehensive moderation and engagement tools