A modular Discord bot for Team Fight Tactics (TFT) rank tracking built with Python 3.11, discord.py v2, and riotwatcher.
/rankcommand to check TFT rankings by Riot ID (Name#Tag)- Real-time rank data including Tier, LP, and W/L records
- Proper error handling for "Not Found" and "Expired Key" scenarios
- Modular architecture with separated concerns (Discord logic, API service)
Pivot/
├── main.py # Bot entry point with async setup_hook
├── cogs/
│ └── tft.py # TFT commands cog
├── services/
│ └── riot_service.py # Riot API service layer
├── requirements.txt # Python dependencies
├── .env.example # Example environment configuration
└── README.md # This file
- Python 3.11+
- Discord Bot Token
- Riot Games API Key
- Clone the repository:
git clone https://github.com/marcoames/Pivot.git
cd Pivot- Install dependencies:
pip install -r requirements.txt- Create a
.envfile from the example:
cp .env.example .env- Edit
.envand add your tokens:
DISCORD_TOKEN=your_discord_bot_token_here
RIOT_API_KEY=your_riot_api_key_here
RIOT_REGION=na1 # Optional, defaults to na1
python main.pyOnce the bot is running and invited to your Discord server:
/rank <Name#Tag>- Get TFT rank information for a player- Example:
/rank Faker#KR1 - Returns: Tier, Rank, LP, Win Rate, and W/L record
- Example:
The bot follows this flow to retrieve player data:
- Account-V1 API: Get PUUID from Riot ID (Name#Tag)
- Summoner-V1 API: Get Summoner ID from PUUID
- League-V1 API: Get TFT ranked data (RANKED_TFT queue)
The bot handles various error scenarios:
- Player Not Found: Returns a friendly message if the player doesn't exist
- Unranked Players: Indicates when a player hasn't played ranked TFT
- Expired API Key: Alerts when the Riot API key is invalid or expired
- Invalid Format: Guides users to use the correct Name#Tag format
- Async/await throughout for optimal performance
- Type hints for better code quality
- Modular architecture for easy maintenance
- Separation of concerns (Discord logic vs. API logic)
discord.py>=2.0.0,<3.0.0- Discord bot frameworkriotwatcher>=3.3.0- Riot Games API wrapperpython-dotenv>=1.0.0- Environment variable management
This project is open source and available under the MIT License.