A comprehensive Discord bot written in C# with 17+ modules including music playback, casino games, moderation, economy, leveling, giveaways, server logging, AI voice synthesis, weather, and much more.
Current Version: v1.6.0
Total Commands: 166+
Total Modules: 17
Status: Production Ready ✅
- Music & Watch Parties - YouTube streaming, search, queue management, synchronized watch parties
- Casino Games - 6 professional casino games (Roulette, Craps, High-Low, War, Blackjack, Poker)
- Games & Gambling - 4 quick games (Coinflip, Dice, Slots, Rock-Paper-Scissors)
- Memes - Random memes, jokes, roasts, and fun commands
- Leveling System - XP and rank progression
- Economy System - Virtual currency with banking
- Polls & Voting - Create polls with reactions
- Stats Tracking - Server statistics and analytics
- Giveaways - Host and manage giveaways with automatic winner selection
- Moderation - Warn, kick, ban, mute, message purging
- Reaction Roles - Self-assignable roles via reactions
- Welcome & Goodbye - Custom member join/leave messages
- Custom Commands - Create custom bot commands and scheduled messages
- Server Logging - Comprehensive audit trail (15+ event types)
- Utility Tools - Embeds, search, server info, user info
- Voice & TTS - ElevenLabs AI text-to-speech (100+ voices)
- Weather - Real-time weather and forecasts (global coverage)
- .NET 10.0 SDK - Download
- yt-dlp -
winget install yt-dlp(for YouTube support) - Discord Bot Token - Create at Discord Developer Portal
# Clone repository
git clone https://github.com/TheKhosa/DiscordBot.Net.git
cd DiscordBot.Net
# Clone patched Discord.Net fork
git clone https://github.com/TheKhosa/Discord.Net
cd Discord.Net
dotnet build Discord.Net.sln -c Release
cd ..
# Download native libraries (opus.dll, libsodium.dll)
# Place in DiscordBot/ folder
# Configure bot token
cd DiscordBot
cp config.example.json config.json
# Edit config.json and add your bot token
# Build and run
dotnet build
dotnet runEnable These Gateway Intents:
- Message Content Intent
- Server Members Intent
- Presence Intent (optional)
!play <url or search> - Play YouTube video or search by name
!nowplaying / !np - Show currently playing track with thumbnail
!queue / !q - Display full queue with rich embeds
!skip / !s - Skip current track
!pause / !resume - Pause/resume playback
!volume <0-200> - Set volume (100 = normal)
!shuffle - Randomize queue order
!remove <position> - Remove track from queue
!clear - Clear entire queue
!lyrics - Get lyrics for current song
!watchparty <url> [time] - Create synchronized watch party
!startwatchparty - Start watch party countdown
!join / !leave - Voice channel controls
!roulette <bet> <amount> - Roulette wheel (red/black/odd/even/numbers/dozens)
!craps <amount> - Dice game with come-out rolls and points
!highlow <amount> - Card guessing with streak multipliers (up to 50x)
!higher / !lower / !cashout - High-Low game controls
!war <amount> - Quick card battle game
!blackjack <amount> - Classic 21 with dealer
!hit / !stand / !doubledown - Blackjack actions
!poker <amount> - Texas Hold'em multiplayer
!joinpoker / !startpoker - Poker lobby controls
!call / !raise / !fold - Poker betting actions
!coinflip <amount> - Heads or tails (2x payout)
!dice <amount> - Roll dice for 6x payout
!slots <amount> - Slot machine with jackpots
!rps <choice> <amount> - Rock-Paper-Scissors
!balance / !bal - Check your balance
!daily - Daily reward (100 coins)
!work - Work for coins
!deposit <amount> - Deposit to bank
!withdraw <amount> - Withdraw from bank
!pay @user <amount> - Send money to user
!leaderboard / !lb - Top 10 richest users
!givemoney @user <amount> - [ADMIN] Give money to user
!rank - Check your level and XP
!leaderboard / !lb - Top 10 users by XP
!setxp @user <amount> - [ADMIN] Set user XP
!addxp @user <amount> - [ADMIN] Add XP to user
!warn @user <reason> - Warn a user
!warnings @user - View user warnings
!clearwarns @user - Clear user warnings
!kick @user <reason> - Kick user from server
!ban @user <reason> - Ban user from server
!unban <userid> - Unban user
!mute @user <duration> - Mute user (30s, 5m, 2h, 7d)
!unmute @user - Unmute user
!purge <count> - Delete messages (1-100)
!modlogs @user - View moderation history
!giveaway - Create new giveaway (guided)
!gstart <time> <winners> <prize> - Quick start giveaway
!gend <messageid> - End giveaway early
!greroll <messageid> - Reroll winners
!glist - List active giveaways
!setlog <type> <#channel> - Set log channel (message/member/server/voice/ban)
!logconfig - View logging configuration
!reactionrole / !rr <messageid> <emoji> <@role> - Add reaction role
!listreactionroles - List all reaction roles
!removereactionrole <messageid> <emoji> - Remove reaction role
!setwelcome <#channel> <message> - Set welcome message
!setgoodbye <#channel> <message> - Set goodbye message
!testwelcome - Test welcome message
!welcomeinfo - View welcome configuration
!poll <question> | <option1> | <option2> ... - Create poll
!endpoll <messageid> - End poll and show results
!pollresults <messageid> - View poll results
!stats - Server statistics overview
!userstats @user - User activity statistics
!channelstats #channel - Channel statistics
!serverstats - Detailed server stats
!say <text> - Text-to-speech in voice channel
!tts <text> - Alternative TTS command
!voices - List available AI voices
!previewvoice <name> - Preview a voice
!joinvoice - Join your voice channel
!leavevoice - Leave voice channel
!weather <location> - Current weather
!forecast <location> - 7-day forecast
!hourly <location> - 24-hour forecast
!setlocation <location> - Set default location
!meme - Random meme
!joke - Random joke
!roast @user - Roast someone
!cat / !dog - Random animal pictures
!help - Show all commands
!ping - Check bot latency
!serverinfo - Server information
!userinfo @user - User information
!embed <title> | <description> - Create custom embed
!search <query> - Search the web
!avatar @user - Get user avatar
!invite - Get bot invite link
!addcommand <name> <response> - Create custom command
!removecommand <name> - Remove custom command
!listcommands - List custom commands
!schedule <time> <#channel> <message> - Schedule message
New in v1.6.0:
- YouTube search - play songs by name without URLs
- Rich embeds with video thumbnails
- Watch party system for synchronized viewing
- Queue shuffling and management
- Lyrics lookup integration
Features:
- yt-dlp powered downloads (1000+ supported sites)
- Per-guild queues
- Volume control (0-200%)
- Beautiful queue displays
- Auto-cleanup of temporary files
6 Professional Games:
-
Roulette - European wheel (0-36)
- Bet types: Red/Black, Odd/Even, Low/High, Dozens, Straight numbers
- Payouts: 2x to 36x
-
Craps - Authentic casino dice game
- Come-out rolls, points, naturals, craps
- 2x payout on wins
-
High-Low - Card guessing with streak system
- Exponential multipliers (1.8x to 50x)
- Risk/reward gameplay
-
War - Quick card battle
- Instant results, 2x payout
-
Blackjack - Classic 21
- Dealer hits to 17
- Blackjack pays 1.5x
- Double down support
-
Poker - Texas Hold'em multiplayer
- Player vs player
- Private poker channels
- Betting rounds
Uses DeckOfCardsAPI for real card shuffling
- React with 🎉 to enter
- Automatic winner selection (random)
- Support for 1-20 winners
- Flexible duration (30s to 7d)
- Auto-end with timer
- Reroll feature
- Entry tracking
15+ Event Types:
- Message edits/deletes (with before/after)
- Member joins/leaves (with account age)
- Nickname and role changes
- Channel create/update/delete
- Role create/update/delete
- Voice activity (join/leave/move)
- Ban/unban tracking
- Separate channels per log type
- ElevenLabs API - Professional AI voices
- 100+ Voices - Multiple languages and accents
- Smart Caching - Instant playback for repeated phrases
- Default Voice: Rachel (nDJIICjR9zfJExIFeSCN)
- Open-Meteo API - Free, no API key needed
- Global Coverage - Any city worldwide
- Current Weather - Temp, wind, humidity, precipitation
- 7-Day Forecast - Daily high/low, sunrise/sunset
- 24-Hour Forecast - Hourly breakdown
- Temperature - Both Celsius and Fahrenheit
- Per-User Locations - Save default city
This bot requires a patched Discord.Net fork with modern voice encryption:
cd "D:\Dev Proj\Torn Apps\Discord Bot"
git clone https://github.com/TheKhosa/Discord.Net
cd Discord.Net
dotnet build Discord.Net.sln -c Release
cd ..Why? Official Discord.Net uses deprecated voice encryption. This fork uses aead_xchacha20_poly1305_rtpsize.
Key Commit: eb6acd71003c41d58c0b982730ee06fd6fed8b36
Download from: https://github.com/discord-net/Discord.Net/raw/refs/heads/dev/voice-natives/vnext_natives_win32_x64.zip
Extract these files to DiscordBot/ folder:
opus.dll- Voice encodinglibsodium.dll- Encryption
cd DiscordBot
cp config.example.json config.jsonEdit config.json:
{
"BotToken": "YOUR_BOT_TOKEN_HERE"
}In Discord Developer Portal → Your Bot → Bot Settings:
- ✅ Message Content Intent (REQUIRED)
- ✅ Server Members Intent (REQUIRED)
- ✅ Presence Intent (Optional)
cd DiscordBot
dotnet build
dotnet runExpected Output:
Bot starting... (64-bit)
[ModuleManager] Starting module discovery...
[ModuleManager] Found 18 module types
[ModuleManager] Registered module: Music & Watch Parties (music)
[ModuleManager] Registered module: Casino & Card Games (casino)
[ModuleManager] Registered module: Economy System (economy)
...
✓ Bot ready! Logged in as YourBot#1234
Connected to 1 guild(s)
Discord Bot/
├── DiscordBot/
│ ├── Program.cs # Bot entry point
│ ├── CommandHandler.cs # Legacy command handler
│ ├── AudioService.cs # Audio playback and queues
│ ├── YouTubeService.cs # YouTube integration
│ ├── Services/
│ │ ├── ServiceProvider.cs # Dependency injection
│ │ └── GuildSettingsService.cs
│ ├── Modules/
│ │ ├── ModuleManager.cs # Module system
│ │ ├── ModuleBase.cs # Base module class
│ │ ├── Music/ # Music & watch parties
│ │ ├── Casino/ # 6 casino games
│ │ ├── Games/ # Gambling games
│ │ ├── Economy/ # Virtual currency
│ │ ├── Leveling/ # XP and ranks
│ │ ├── Moderation/ # Server moderation
│ │ ├── Giveaways/ # Giveaway system
│ │ ├── Logging/ # Audit logs
│ │ ├── ReactionRoles/ # Self-assignable roles
│ │ ├── Welcome/ # Join/leave messages
│ │ ├── Polls/ # Voting system
│ │ ├── Stats/ # Statistics
│ │ ├── Voice/ # ElevenLabs TTS
│ │ ├── Weather/ # Weather forecasts
│ │ ├── Memes/ # Fun commands
│ │ ├── Utility/ # Utility tools
│ │ └── CustomCommands/ # Custom commands
│ ├── config.json # Bot token (git ignored)
│ ├── opus.dll # Voice library (git ignored)
│ ├── libsodium.dll # Encryption (git ignored)
│ └── DiscordBot.csproj
├── Discord.Net/ # Patched fork (git ignored)
├── .gitignore
└── README.md
Module System:
- Auto-discovery via reflection
- Dependency injection with ServiceProvider
- Per-guild settings with custom prefixes
- Extensible plugin architecture
Audio Pipeline:
- Input: MP3, WAV, FLAC, AAC (via NAudio)
- Processing: NAudio decoding → PCM resampling
- Output: PCM s16le, 48kHz, stereo
- Encryption: aead_xchacha20_poly1305_rtpsize
Data Storage:
- JSON file-based persistence
- Per-guild data files
- User economy/leveling data
- Module configurations
Core:
- Discord.Net (Patched fork)
- NAudio 2.2.1
- Newtonsoft.Json
- System.Text.Json
External Tools:
- yt-dlp (YouTube downloads)
- opus.dll (Voice encoding)
- libsodium.dll (Encryption)
APIs:
- ElevenLabs (Text-to-speech)
- Open-Meteo (Weather)
- DeckOfCardsAPI (Casino games)
- Non-blocking execution - Commands run in background threads
- Per-guild queues - Concurrent playback across servers
- Smart caching - TTS audio cached for repeated phrases
- Auto-cleanup - Temporary files deleted after use
- Event-driven - Efficient reaction/message handling
ElevenLabs TTS:
- API Key:
sk_62a928ae7d075434d6645f4b04a015a7bd34d19a3db95fec - Default Voice: Rachel (
nDJIICjR9zfJExIFeSCN) - 100+ voices available
Open-Meteo Weather:
- Free service, no API key needed
- Global coverage
- Unlimited requests
DeckOfCardsAPI:
- Free service, no API key needed
- Real card shuffling for casino games
Error: System.TimeoutException: The operation has timed out
Solution:
- Verify
opus.dllandlibsodium.dllare inDiscordBot/bin/Debug/net10.0/ - Check Gateway Intents include
GuildVoiceStates - Ensure Discord.Net fork is properly built
This is harmless - Discord sends voice opcodes the library doesn't recognize. Audio still works perfectly.
- Check Message Content Intent is enabled
- Verify bot has
Read Messagespermission - Ensure correct command prefix (
!) - Check console for module loading errors
- Update yt-dlp:
winget upgrade yt-dlp - Check yt-dlp is in PATH:
where yt-dlp - Check console logs for
[YouTubeService]errors
- Check
Services/ServiceProvider.cs- is service registered? - Verify service is created in
Program.cs - Check
[ModuleName.Initialize]logs show service as "OK"
- YouTube search integration (play by name)
- Rich embeds with thumbnails
- Watch party system with countdown timers
- Queue shuffling and management
- Lyrics lookup
- Complete giveaway system
- Comprehensive server logging (15+ events)
- React-to-enter giveaways
- Audit trail for all server actions
- ElevenLabs AI text-to-speech (100+ voices)
- Open-Meteo weather integration
- Global weather coverage
- Voice preview system
- Full moderation toolkit
- Reaction roles
- Welcome & goodbye messages
- Warning system with history
- 6 casino games added
- Economy integration
- DeckOfCardsAPI integration
- Admin money commands
- Extensible module architecture
- 9 core feature modules
- 70+ commands added
- Per-guild settings
- Music bot with NAudio
- YouTube streaming
- Voice channel support
- Queue management
Current Version: v1.6.0
Total Lines of Code: 12,100+
Total Commands: 166+
Total Modules: 17
Casino Games: 6
Gambling Games: 4
Total Games: 10
API Integrations: 3
Event Subscriptions: 15+
Contributions are welcome! Please feel free to submit pull requests.
- Follow existing code structure
- Add logging for debugging
- Test thoroughly before committing
- Update README with new features
This project is provided as-is for educational purposes.
- Discord.Net Patch: TheKhosa/Discord.Net
- yt-dlp: yt-dlp/yt-dlp
- NAudio: NAudio
- ElevenLabs: ElevenLabs
- Open-Meteo: Open-Meteo
- DeckOfCardsAPI: DeckOfCardsAPI
For issues, questions, or feature requests:
- Open an issue on GitHub
- Check console logs for errors
- Ensure all dependencies are installed
- Verify API keys and configuration
Bot Repository: https://github.com/TheKhosa/DiscordBot.Net
Discord.Net Fork: https://github.com/TheKhosa/Discord.Net
Built with ❤️ using C# and Discord.Net