A comprehensive Discord bot that integrates with ESPN Fantasy Football API to provide real-time league data, analytics, and interactive features for your fantasy football server.
Note: This is a personal project shared for educational purposes. Feel free to use and modify for your own needs, but please note that active maintenance and support are not guaranteed.
- Multi-League Support - Register and manage multiple ESPN Fantasy leagues
- Real-Time Data - Live scoring, standings, and player statistics
- Advanced Analytics - In-depth team comparisons, trade analysis, and waiver wire recommendations
- Interactive Commands - Visual team cards, scoreboards, and matchup analysis
- Cross-League Comparisons - Compare teams from different leagues
- Private League Support - Full access to private ESPN leagues with authentication
- Python 3.8 or higher
- Discord Developer Account
- ESPN Fantasy Football League (public or private)
-
Clone the repository
git clone https://github.com/ryanmachancock/ff-discord-bot.git cd ff-discord-bot -
Install dependencies
pip install -r requirements.txt
-
Create environment file
cp .env.example .env
-
Configure your bot (see Configuration section)
-
Run the bot
python bot.py
- Go to the Discord Developer Portal
- Create a new application and bot
- Copy the bot token
- Invite the bot to your server with appropriate permissions
Edit your .env file with the following configuration:
# Discord Bot Configuration
DISCORD_TOKEN=your_discord_bot_token_here
# ESPN Fantasy Football League Configuration
ESPN_LEAGUE_ID=your_league_id_here
ESPN_SEASON_ID=2025
# ESPN Authentication (Required for private leagues only)
ESPN_SWID=your_swid_cookie_value_here
ESPN_S2=your_espn_s2_cookie_value_hereFor private leagues, you'll need to get your ESPN authentication cookies:
- Login to ESPN Fantasy Football
- Open browser developer tools (F12)
- Go to Application/Storage → Cookies → fantasy.espn.com
- Find and copy the values for:
SWID(including the curly braces)espn_s2(long URL-encoded string)
Note: Public leagues don't require ESPN authentication credentials.
| Command | Description | Parameters |
|---|---|---|
/team |
Get detailed roster for a team | team_name |
/compare |
Compare two teams side-by-side | team1, team2 |
/player |
Get detailed stats for a specific player | player_name |
/card |
Generate visual team card with stats | team_name |
| Command | Description | Parameters |
|---|---|---|
/standings |
View league standings with records | None |
/stats |
Show detailed league analytics | None |
/scoreboard |
Live updating scoreboard for current week | auto_refresh (optional) |
/league_info |
Display league settings and configuration | None |
| Command | Description | Parameters |
|---|---|---|
/matchup |
Player-by-player matchup analysis | team1, team2 (optional) |
/trade |
Analyze potential trades between teams | team1, team2, give_players, get_players |
/waiver |
Top waiver wire pickup recommendations | position, min_owned, max_owned |
/sleeper |
Find undervalued sleeper picks | position (optional) |
| Command | Description | Parameters |
|---|---|---|
/register_league |
Register a new ESPN league | league_id, league_name, year, swid, espn_s2 |
/my_leagues |
View your registered leagues | None |
/switch_league |
Switch your default league | league_name |
/remove_league |
Remove a league from your account | league_name |
/all_leagues |
View all available server leagues | None |
/compare_cross_league |
Compare teams from different leagues | team1, league1, team2, league2 |
| Command | Description | Parameters |
|---|---|---|
/menu |
Interactive command menu | None |
/help |
Quick command reference | None |
/welcome |
Complete setup and usage guide | None |
/league_status |
Show current default league and status | None |
/ping |
Check if bot is responsive | None |
The bot supports managing multiple ESPN leagues simultaneously:
- Use
/register_leagueto add each of your leagues - Use
/switch_leagueto change your default league - Use
/compare_cross_leagueto compare teams across different leagues - Use
/all_leaguesto see all available leagues in your server
For private leagues, you'll need to provide ESPN authentication:
/register_league league_id:123456 league_name:"My Private League" year:2025 swid:"{YOUR-SWID}" espn_s2:"YOUR-ESPN-S2-COOKIE"Use /menu to access an interactive button-based interface for easier command navigation.
Bot not responding to commands:
- Check that the bot has proper permissions in your Discord server
- Verify the bot token is correct in your
.envfile - Use
/pingto test basic connectivity
"League not found" errors:
- Verify your league ID is correct (found in ESPN URL)
- For private leagues, ensure SWID and espn_s2 cookies are valid
- Check that the season year matches your league settings
ESPN API timeout errors:
- ESPN API can be slow during peak times (Sunday game days)
- The bot includes automatic retry logic for temporary failures
- Commands will show "Fetching data..." while processing
- Use
/helpfor a quick command reference - Use
/welcomefor a comprehensive setup guide
See requirements.txt for the complete list of Python dependencies. Key libraries include:
discord.py- Discord bot frameworkespn-api- ESPN Fantasy Sports API wrapperpython-dotenv- Environment variable management
Note: This bot is not affiliated with ESPN or Discord. ESPN Fantasy Football is a trademark of ESPN, Inc.



