Esports Discord Bot: Match Schedules, Live Scores, and Odds on Your Server
How to build a Discord bot that shows CS2 and Dota 2 match schedules, live scores, and odds: data from SportAPI, Python code, and automatic posting to a channel.

An esports Discord bot is a small script that takes data from an API and posts it on your server: today’s schedule, live scores by map, and odds. The data comes from the SportAPI esports API: Counter-Strike 2, Dota 2, and other disciplines, prematch and live, markets and odds in JSON. A plan for one discipline starts at $25 a month, and you can test everything with a 2-day trial key.
Below: what such a bot can do, how to get CS2 and Dota 2 matches from the API, ready-to-run Python code with a /matches command and automatic posting, and how to keep the channel from turning into spam.
What an esports bot can do
| Feature | How it works | SportAPI data |
|---|---|---|
/matches command | A member gets upcoming matches on request | Prematch matches of the discipline |
| Daily schedule | The bot posts the match list to a channel on a schedule | Prematch matches of the discipline |
| Live score | The bot reports when the map score changes | Live matches: total score and current map score |
| Odds | The main market next to each match | Match markets and odds |
| Results | In the evening — who won today’s matches | Live matches and results |
Admins update nothing by hand: the bot runs 24/7, and the server gets a living channel that brings members back more often.
How to get CS2 and Dota 2 matches from the API
Esports in SportAPI uses the same methods as sports, with the cybersport=true parameter:
GET https://YOUR_API_DOMAIN/v1/menu/line/en?cybersport=true
GET https://YOUR_API_DOMAIN/v1/events/{sportId}/0/sub/50/line/en?cybersport=true
GET https://YOUR_API_DOMAIN/v1/events/{sportId}/0/sub/50/live/en?cybersport=true
Package: YOUR_API_KEY
menureturns disciplines, tournaments, and their IDs. In the sports reference, Counter-Strike hassport_id86 and Dota has 97, but always take IDs from the currentmenuresponse.eventswith thelinetype returns upcoming matches of the discipline with the main markets.eventswith thelivetype returns matches in progress: the total scorescore_full, the current map scorescore_period, and its nameperiod_name.
For esports, events always returns the full match list of the discipline, without the “Top” selection. Full method and field descriptions are in the events method documentation.
A Python bot: the /matches command and automatic posting
You need Python 3.10+, the discord.py library, and a bot created in the Discord Developer Portal and invited to your server with permission to send messages. Keep the SportAPI key and the bot token in environment variables, not in the code.
import os
from datetime import datetime
import aiohttp
import discord
from discord import app_commands
from discord.ext import tasks
API = "https://YOUR_API_DOMAIN/v1"
HEADERS = {"Package": os.environ["SPORTAPI_KEY"]}
CS2_SPORT_ID = 86 # check it in the menu response with cybersport=true
CHANNEL_ID = 123456789012345678 # channel for the schedule
client = discord.Client(intents=discord.Intents.default())
tree = app_commands.CommandTree(client)
async def fetch_matches(kind="line"):
url = f"{API}/events/{CS2_SPORT_ID}/0/sub/50/{kind}/en?cybersport=true"
async with aiohttp.ClientSession(headers=HEADERS) as session:
async with session.get(url, timeout=aiohttp.ClientTimeout(total=10)) as response:
response.raise_for_status()
data = await response.json()
return [(t["tournament_name"], m) for t in data["body"] for m in t["events_list"]]
def format_match(tournament, match):
start = datetime.fromtimestamp(match["game_start"]).strftime("%d.%m %H:%M")
line = f'**{match["opp_1_name"]}** vs **{match["opp_2_name"]}** · {start}\n{tournament}'
groups = match.get("game_oc_list", [])
if groups:
odds = " · ".join(f'{o["oc_name"]} {o["oc_rate"]}' for o in groups[0]["oc_list"])
line += f"\n{groups[0]['group_name']}: {odds}"
return line
def build_embed(matches, title):
embed = discord.Embed(title=title, color=0xC2FF1F)
embed.description = "\n\n".join(format_match(t, m) for t, m in matches[:8]) or "No matches"
return embed
@tree.command(name="matches", description="Upcoming CS2 matches with odds")
async def matches_command(interaction: discord.Interaction):
matches = await fetch_matches("line")
await interaction.response.send_message(embed=build_embed(matches, "Upcoming CS2 matches"))
@tasks.loop(hours=6)
async def post_schedule():
channel = client.get_channel(CHANNEL_ID)
matches = await fetch_matches("line")
await channel.send(embed=build_embed(matches, "CS2 schedule"))
@client.event
async def on_ready():
await tree.sync()
if not post_schedule.is_running():
post_schedule.start()
client.run(os.environ["DISCORD_TOKEN"])
What the code does:
fetch_matchesrequests the discipline’s matches:linefor upcoming,livefor current ones.format_matchbuilds a match line: teams, time, tournament, and the first market group from the short odds set./matchesis a command members call themselves.post_scheduleposts the schedule to the chosen channel every 6 hours.
To add Dota 2, use a second sport_id and a separate command or a command parameter.
Live scores by map
Live notifications compare two requests:
- Every 30–60 seconds the bot requests
eventswith thelivetype. - It compares each match’s
score_fullandscore_periodwith the previous request. - If the score changed, it posts a message: “NAVI 1–0 Vitality, map 2 8–5”.
The documentation recommends requesting the live match list no more often than every 7 seconds, so the bot has plenty of headroom. Post changes only for matches your server cares about — for example, top tournaments or the teams in members’ roles.
How to grow the bot further
Once the schedule and live scores work, the bot can become the center of activity on your server:
- Member predictions. Before a match the bot posts a message with a reaction for each team, members vote, and after the match the bot announces the result.
- A leaderboard. The bot tracks who picks winners most often and posts a weekly ranking — a good reason to come back regularly.
- Tournament recaps. When a tournament ends, the bot collects all match results in one message.
- Several disciplines. Separate channels for CS2, Dota 2, and League of Legends, each with its own subscription role.
- Your own website. As the server grows, the same data feed can power a community site with a full schedule and live section.
All of these features use the same API methods — only the bot logic changes.
How to keep the channel from turning into spam
- A separate channel for the bot. Schedules and live scores go to
#matchesso they do not get in the way of conversation. - No more than 8 matches per message. Nobody reads long lists; offer the
/matchescommand for the rest. - Only important changes. Map scores and the final result, not every round.
- Subscription roles. Mention a role such as
@cs2-liveonly for match start and end messages. - Odds according to your server’s and the platform’s rules. If your audience does not need them, remove the market line — the bot stays useful as a schedule and live score feed.
What it costs and how to test it
| What you need | Cost |
|---|---|
| Data for one discipline: matches, prematch and live, markets, odds, short live statistics | from $25 a month |
| Bot hosting | Any inexpensive server or container |
| Testing before you pay | 2-day SportAPI trial key, all disciplines |
If you also need football or basketball, the same bot works with the Sports Odds API: only the sport_id and the cybersport parameter change.
FAQ
Which disciplines does the bot support?
Any discipline in the SportAPI esports line: Counter-Strike 2, Dota 2, League of Legends, and others. The current list with IDs comes from menu with cybersport=true.
Can I do it without code?
A simple option is n8n or a similar builder: a schedule, a SportAPI request, and a message through a Discord webhook. But commands like /matches and live notifications are easier with the code in this article.
How often should the live score update?
Every 30–60 seconds is enough for a bot. SportAPI documentation allows requesting the live match list as often as every 7 seconds.
Do I need to show odds?
No. Odds help gauge the favorite, but the bot is useful without them — as a schedule and live score feed. Follow your server’s and Discord’s rules.
Can I check the data before paying?
Yes. The 2-day trial key includes all disciplines, prematch and live — enough to run the bot from this article on your server.
What to do today
- Create a bot in the Discord Developer Portal and invite it to your server.
- Get a SportAPI trial key.
- Check the discipline ID with
menuandcybersport=true. - Run the code from this article and call
/matches. - Add live map score notifications for the tournaments your server follows.
Message the SportAPI manager on Telegram with the disciplines your server needs — you will get a trial key for the esports API and can launch the bot the same day.