A powerful, feature-rich Discord bot with advanced moderation, music streaming, automated systems, and a comprehensive web dashboard.
- Features
- Tech Stack
- Installation
- Configuration
- Usage
- Commands
- Dashboard
- Security
- Contributing
- Support
- Complete moderation suite with ban, kick, mute, warn commands
- Auto-Moderation system with customizable rules
- Anti-spam protection with progressive penalties
- Anti-links, anti-invites, anti-banned words filters
- Anti-new accounts protection
- Flexible penalty system (warn, mute, kick, ban)
- Warning system with persistent storage and history tracking
- Moderation dashboard with real-time statistics and configuration
- Channel management with lock/unlock and slowmode controls
- Bulk message deletion with purge command
- High-quality music playback via Lavalink
- Multiple sources support:
- YouTube
- Spotify
- SoundCloud
- Custom yt-dlp integration
- Advanced queue management
- Play, skip, stop, pause, resume
- Queue shuffle and loop (song/queue/none)
- Song seek functionality
- Queue visualization and management
- Music controls via buttons for better UX
- Lyrics display with multiple API fallbacks (including Vagalume)
- Song statistics with caching for performance
- Multiple Lavalink nodes with automatic failover
- Complete ticket lifecycle management
- Dashboard panel for creation and configuration
- Ticket statistics and history tracking
- Category organization support
- Automated templates for messages and logging
- Webhook integration for notifications
- User information commands (profile, avatar, guild info)
- Server management tools
- Fun commands and games
- Configuration commands for server-specific settings
- Help system with command categories
- Message filtering with categories
- Discord OAuth2 authentication for secure login
- Server management interface
- Real-time statistics and status
- Bot settings configuration
- Music queue control from the web
- Command and feature management
- Responsive design with Bootstrap 5
- Modern UI components and alerts system
- Role-based access control (RBAC)
- Webhook validation and secure integration
- Input sanitization and validation
- Extended security queries for Node.js
- Secret management via environment variables
- Audit logging with detailed action tracking
| Component | Technology | Version |
|---|---|---|
| Runtime | Node.js | >= 20.11.1 |
| Discord Library | discord.js | v14 |
| Music System | Lavalink Client | v2.9.7 |
| Web Framework | Express | v5.2.1 |
| Template Engine | EJS | v5.0.1 |
| Database | MongoDB + Mongoose | v9.2.1 |
| Session Store | express-session | v1.19.0 |
| Authentication | Passport (Discord) | v0.7.0 |
| Security | Helmet | v8.0.0 |
| Audio Processing | libsodium-wrappers | v0.8.2 |
| Media Sources | play-dl, youtubei.js, yt-dlp | Latest |
- Node.js >= 20.11.1
- npm or yarn
- MongoDB (local or Atlas)
- Discord Bot Token
- (Optional) Spotify API credentials
- (Optional) Lavalink server for music
# Clone the repository
git clone https://github.com/Programador-jr/King.git
cd King
# Install dependencies
npm install
# Copy environment template
cp .env.example .env
# Edit .env with your credentials
nano .env# ============================================
# DISCORD BOT
# ============================================
TOKEN=YOUR_BOT_TOKEN_HERE
PREFIX=k
# ============================================
# DATABASE
# ============================================
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/king
DNS_RESULT_ORDER=ipv4first
# ============================================
# SPOTIFY INTEGRATION (Optional)
# ============================================
SPOTIFY_API_ENABLED=true
SPOTIFY_CLIENT_ID=YOUR_SPOTIFY_CLIENT_ID
SPOTIFY_CLIENT_SECRET=YOUR_SPOTIFY_CLIENT_SECRET
# ============================================
# DASHBOARD & OAUTH
# ============================================
DASHBOARD_CLIENT_ID=YOUR_DISCORD_CLIENT_ID
DASHBOARD_CLIENT_SECRET=YOUR_DISCORD_CLIENT_SECRET
DASHBOARD_DOMAIN=http://localhost:5000
DASHBOARD_CALLBACK=http://localhost:5000/callback
DASHBOARD_SESSION_SECRET=YOUR_VERY_LONG_RANDOM_SECRET_KEY_HERE
# ============================================
# MUSIC SOURCES (Optional)
# ============================================
VAGALUME_API_KEY=YOUR_VAGALUME_KEY_HERE
YTDLP_PATH=/path/to/yt-dlp
# ============================================
# ENVIRONMENT
# ============================================
NODE_ENV=production
PORT=5000Stores non-sensitive bot settings:
{
"token": "YOUR_BOT_TOKEN",
"prefix": "k",
"defaultColor": "#2b2d31",
"errorColor": "#ed4245",
"successColor": "#57f287"
}Dashboard structural settings:
{
"antiCrash": true,
"port": 5000,
"https": false,
"domain": "localhost"
}- Go to Discord Developer Portal
- Create a New Application
- Go to OAuth2 > Redirects
- Add your callback URL:
- Local:
http://localhost:5000/callback - Production:
https://yourdomain.com/callback
- Local:
- Copy Client ID and Client Secret to
.env
# Production
npm start
# Development (with auto-reload)
npm run devThe bot will:
- Connect to Discord
- Load all commands and events
- Connect to Lavalink for music
- Start the web dashboard on
http://localhost:5000
- Open
http://localhost:5000in your browser - Click "Login with Discord"
- Authorize the application
- Access your server's settings
- Configure moderation, music, and bot features
play- Play a song from YouTube, Spotify, or SoundCloudskip- Skip current songstop- Stop music and clear queuepause- Pause current playbackresume- Resume paused songqueue- View current queueloop- Toggle loop modes (off, song, queue)shuffle- Shuffle queueseek- Jump to specific time in songlyrics- Get lyrics for current or specified song
ban- Ban a user from serverkick- Remove user from servermute- Mute a user (timeout)unmute- Remove mute from userwarn- Issue warning to userunwarn- Remove specific warningwarnings- View user's warningsclearwarnings- Remove all user warningslock- Lock channel for publicunlock- Unlock channelslowmode- Set channel message rate limitpurge- Delete bulk messages
q/queue- Display current queueremove- Remove song from queueclear- Clear entire queuemove- Move song position in queue
bassboost- Enable bass boostnightcore- Nightcore effectvaporwave- Vaporwave effectclear- Remove all filters
create- Create support ticketclose- Close active ticketadd- Add user to ticketremove- Remove user from ticketsettings- Configure ticket system
help- Show help informationbotinfo- Bot statistics and infoserverinfo- Server informationuserinfo- User profile informationavatar- Get user's avatar
automod- Configure auto-moderationprefix- Change command prefixsettings- Manage server settings
- Secure Discord OAuth2 login
- Session management with express-session
- Role-based access control
- Home - Overview and quick stats
- Server Settings - Configure bot behavior
- Moderation - Set up AutoMod rules and warnings
- Music - Queue controls and filter management
- Tickets - Create and manage ticket panels
- Logs - View action history and audit trail
- Never commit
.envfile - It contains sensitive credentials - Rotate tokens regularly - If exposed, regenerate immediately
- Use strong secrets - For
DASHBOARD_SESSION_SECRET - MongoDB authentication - Use strong passwords and IP whitelist
- HTTPS in production - Always use SSL/TLS
- Helmet enabled - Security headers middleware active
- Input validation - All user inputs are sanitized
- RBAC system - Granular permission management
- All secrets in
.env(never in code) - Different credentials per environment
- Webhook URL validation
- Role-based bypass system for AutoMod
# Check Node version
node --version # Should be >= 20.11.1
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install
# Check environment variables
cat .env# Verify MongoDB URI
# Check: IP whitelist in MongoDB Atlas
# Check: Network connectivity
# Try: DNS_RESULT_ORDER=ipv4first in .env# Verify Lavalink server is running
# Check: Bot has voice permissions
# Check: User is in voice channel
# Logs: Check console for Lavalink errors# Check: Dashboard server is running on PORT 5000
# Check: OAuth credentials are correct
# Check: Callback URL matches Discord settings
# Logs: Check console for Express errorsContributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues - Open an issue on GitHub
- Discussions - Join our GitHub Discussions
- Discord - Check our support channel
Give this project a ⭐ if it helped you! It means a lot.