A Discord bot that monitors League of Legends and Teamfight Tactics (TFT) players' ranked games and notifies a Discord channel when they lose a ranked match.
- Tracks multiple summoners listed in config.json
- Monitors both League of Legends and Teamfight Tactics ranked games
- Checks for new matches every minute using cron jobs
- Generates custom images with game data:
- For League: champion played, KDA, and rank info
- For TFT: placement, level, and rank info
- Only triggers notifications for ranked losses (not wins or non-ranked games)
- For League: losses in ranked queue 420
- For TFT: placements 5th-8th in ranked queue 1100
- Includes Discord slash commands for easily managing tracked summoners:
/addsummoner- Add a new summoner to track/listsummoners- View all currently tracked summoners/removesummoner- Remove a summoner from tracking
- Legacy command support with
!addsummonerfor backward compatibility
- Converted codebase to TypeScript for better type safety and maintainability
- Implemented Discord slash commands for improved user experience
- Implemented modular architecture with services and clear separation of concerns
- Added caching to reduce API calls
- Added error handling and graceful shutdown
- Used environment variables for sensitive information
- Added better validation and error logging
- Node.js 16+
- npm or yarn
- Discord Bot Token
- Riot Games API Key
- Clone the repository:
git clone https://github.com/yourusername/hatewatcher.git
cd hatewatcher- Install dependencies:
npm install- Create a
.envfile in the root directory with your Discord and Riot API tokens:
# Bot Configuration
RIOT_API_KEY=your_riot_api_key_here
DISCORD_TOKEN=your_discord_token_here
DISCORD_CHANNEL_ID=your_discord_channel_id_here
TFT_DISCORD_CHANNEL_ID=your_tft_discord_channel_id_here (optional)
REGION=americas
- Build the TypeScript files:
npm run build- Start the bot:
npm startThe bot supports the following slash commands:
/addsummoner riot_id:<n>#<Tagline> discord_user:@User- Add a new summoner to track/listsummoners- List all currently tracked summoners/removesummoner riot_id:<n>#<Tagline>- Remove a summoner from tracking
For backward compatibility, the bot still supports the old command format:
!addsummoner <SummonerName>#<Tagline> <DiscordUserId>- Add a new summoner to track
You can use either the .env file or the config.json file to configure the bot. Here's a sample config.json:
{
"summoners": [
{
"name": "SummonerName",
"tagline": "tagline",
"discordUsername": "discordUsername",
"lastMatchId": null,
"lastTFTMatchId": null
}
],
"region": "americas",
"riotApiKey": "RIOT API KEY",
"discordToken": "DISCORD TOKEN KEY",
"discordChannelId": "DISCORD CHANNEL ID",
"tftDiscordChannelId": "TFT DISCORD CHANNEL ID (OPTIONAL)",
"guildId": "GUILD ID (OPTIONAL - FOR COMMAND REGISTRATION)"
}If tftDiscordChannelId is not specified, TFT loss notifications will be sent to the main Discord channel (discordChannelId).
npm run build- Build the TypeScript filesnpm run dev- Run in development mode with hot reloadingnpm start- Start the botnpm run lint- Run ESLint
src/- Source codecommands/- Discord slash command definitions and handlersservices/- Service modulestypes/- TypeScript type definitions
assets/- Image assetsbackground/- Background imageschampion_icons/- Champion iconsranked_icons/- Ranked emblems
data/- Storage for rank data
MIT
You can deploy this bot for free on Render.com:
-
Push your code to a GitHub repository.
-
Sign up for an account at Render.com.
-
From the Render dashboard, click "New" and select "Web Service".
-
Connect your GitHub account and select your repository.
-
Configure your service:
- Name:
hatewatcher-bot(or any name you prefer) - Environment:
Docker - Branch:
main(or your preferred branch) - Plan:
Free
- Name:
-
Add the following environment variables:
REGION: americas (or your preferred region)RIOT_API_KEY: Your Riot API keyDISCORD_TOKEN: Your Discord bot tokenDISCORD_CHANNEL_ID: Your Discord channel IDTFT_DISCORD_CHANNEL_ID: (Optional) Your TFT Discord channel IDGUILD_ID: (Optional) Your Discord server ID
-
Click "Create Web Service" and Render will automatically deploy your bot.
Note: On the free tier, Render will spin down your service after 15 minutes of inactivity. The first request after inactivity may take a few seconds to respond while the service spins up again. However, since your bot is making regular API calls, it should stay active.