A feature-rich Discord bot for internal League of Legends servers with Vietnamese-speaking users. Provides post-game analysis with AI-generated trash talk, betting system, leaderboards, and rank synchronization.
- 🏆 Post-Game Analysis: Automatic match detection with AI-generated Vietnamese trash talk
- 💰 Betting System: Virtual currency betting on match outcomes with dynamic odds
- 📊 Leaderboards: Weekly rankings across multiple categories (kills, deaths, games played, rank)
- 🎭 Role Management: Automatic Discord role updates based on League rank, MVP/Feeder awards
- 🤖 AI Integration: OpenAI or Google Gemini for personalized roasting
- Node.js 18+ and npm
- Discord Bot Token (Discord Developer Portal)
- Riot Games API Key (Riot Developer Portal)
- OpenAI API Key (OpenAI Platform) or Gemini API Key
- MongoDB instance (local or MongoDB Atlas)
-
Clone the repository
git clone <repository-url> cd discord_bot
-
Install dependencies
npm install
-
Configure environment variables
cp .env.example .env # Edit .env with your API keys and configuration -
Deploy slash commands
npm run deploy-commands
-
Start the bot
# Development mode (with auto-reload) npm run dev # Production mode npm start
Create a .env file based on .env.example:
# Discord
DISCORD_TOKEN=your_bot_token
DISCORD_CLIENT_ID=your_client_id
GUILD_ID=your_server_id
TRACKED_CHANNEL_ID=your_channel_id
# Riot API
RIOT_API_KEY=your_riot_key
# AI (choose one)
OPENAI_API_KEY=your_openai_key
# GEMINI_API_KEY=your_gemini_key
# Database
MONGODB_URI=mongodb://localhost:27017/discord_lol_bot
# Environment
NODE_ENV=development- Go to Discord Developer Portal
- Create a new application
- Go to "Bot" tab and create a bot
- Enable these Privileged Gateway Intents:
- Server Members Intent
- Message Content Intent
- Go to "OAuth2" → "URL Generator"
- Select scopes:
bot,applications.commands - Select permissions:
Manage Roles,Send Messages,Embed Links,Read Message History - Use generated URL to invite bot to your server
| Command | Description |
|---|---|
/link [GameName#Tag] |
Link your Riot account |
/unlink |
Unlink your Riot account |
/refresh |
Check for new completed matches |
/openbet |
Open betting window before your game |
/bet [option] [amount] |
Place a bet on ongoing match |
/balance |
Check your coin balance |
/leaderboard |
View weekly rankings |
/stats [@user] |
View personal statistics |
/random |
Randomly assign roles for 5v5 custom |
/help |
Show all available commands |
- Link Account:
/link YourName#VN2 - Before Game:
/openbet(opens 5-minute betting window) - Others Bet:
/bet win 100or/bet loss 50 - Play Game: Play League of Legends normally
- After Game:
/refresh(bot analyzes match and settles bets) - View Stats:
/leaderboardto see weekly rankings
discord_bot/
├── src/
│ ├── commands/ # Slash command handlers
│ ├── features/ # Core bot features
│ ├── services/ # External API integrations
│ ├── utils/ # Utility functions
│ ├── config/ # Configuration
│ └── index.js # Entry point
├── .env # Environment variables
├── package.json # Dependencies
└── README.md # This file
-
Create Railway account at railway.app
-
Connect GitHub repository
git init git add . git commit -m "Initial commit" git remote add origin <your-repo-url> git push -u origin main
-
Deploy on Railway
- Connect GitHub repository in Railway dashboard
- Add MongoDB plugin or use MongoDB Atlas
- Configure environment variables in Railway dashboard
- Deploy automatically on push
-
Set environment variables in Railway dashboard
See CLAUDE.md for detailed deployment instructions.
npm run devUses nodemon for auto-reload on file changes.
After modifying commands:
npm run deploy-commands- Users: Discord ID, Riot PUUID, summoner name, currency, linked date
- Matches: Match ID, participants, MVP, feeder, stats, timestamp
- Bets: User ID, match ID, bet type, amount, odds, result
- Leaderboard: User ID, week, kills, deaths, games, rank
- 20 requests/second
- 100 requests/2 minutes
- Note: Development keys expire every 24 hours
- ~10 users × 3 games/day = 30 API calls/day
- Well within free tier limits
- 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.
This bot is not endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing League of Legends. League of Legends and Riot Games are trademarks or registered trademarks of Riot Games, Inc.
For detailed documentation, see CLAUDE.md.
For issues or questions, please open an issue on GitHub.
- Implement post-game analysis
- Add betting system
- Create leaderboard feature
- Add rank-role sync
- Implement AI trash talk
- Add shop system (nickname colors, mute privileges)
- Support multiple languages
- Add match history visualization
- Implement tournament mode
Made with ❤️ for the League of Legends community