MATCH_COMPLETED
Triggered when a match finishes and a winner is determined.
Example Payload
{
"action": "MATCH_COMPLETED",
"queue": "valorant",
"channel": "1234567890123456789",
"guild": "9876543210987654321",
"teams": [
[
{
"name": "Player1#1234",
"id": "111222333444555666",
"mmr": 1500,
"role": "Duelist",
"team_num": 0,
"top_role_index": 0,
"ign": "PlayerIGN1",
"timestamp": 1707523200.0,
"pulled_from": null
}
],
[
{
"name": "Player3#9012",
"id": "333444555666777888",
"mmr": 1480,
"role": "Sentinel",
"team_num": 1,
"top_role_index": 2,
"ign": "PlayerIGN3",
"timestamp": 1707523300.0,
"pulled_from": null
}
]
],
"winning_team_index": 0
}
Payload Fields
| Field | Type | Description |
|---|---|---|
action | string | Always "MATCH_COMPLETED" |
queue | string | The name/identifier of the queue |
channel | string | Discord channel ID where the event occurred |
guild | string | Discord guild (server) ID |
teams | Player[][] | 2D array of teams |
winning_team_index | number | Index of the winning team (0, 1, etc.) |
When This Event Fires
This webhook is sent when:
- A winner vote completes
- A moderator selects a winner
- An automated result is determined
tip
Use winning_team_index to identify the winning team: teams[winning_team_index]
Use Cases
- Update player MMR and statistics
- Record match results in database
- Calculate ELO/rating changes
- Generate match summary reports
- Award points or rewards
- Update leaderboards
- Trigger post-match surveys
Implementation Example
def handle_match_completed(data):
teams = data['teams']
winning_index = data['winning_team_index']
queue_name = data['queue']
winning_team = teams[winning_index]
losing_teams = [t for i, t in enumerate(teams) if i != winning_index]
print(f"Match completed in {queue_name}")
print(f"Team {winning_index} won!")
# Update player stats
for player in winning_team:
update_player_stats(
player_id=player['id'],
result='win',
queue=queue_name
)
for team in losing_teams:
for player in team:
update_player_stats(
player_id=player['id'],
result='loss',
queue=queue_name
)
# Calculate MMR changes
calculate_mmr_changes(teams, winning_index)
Determining Winners and Losers
def process_match_result(data):
teams = data['teams']
winning_index = data['winning_team_index']
# Get winning team
winners = teams[winning_index]
# Get losing teams (handles 2+ team scenarios)
losers = []
for i, team in enumerate(teams):
if i != winning_index:
losers.extend(team)
return winners, losers
Match Flow
- MATCH_STARTED - Match validation begins
- TEAMS_CREATED - Teams are formed
- MATCH_COMPLETED ← You are here
Related Events
- TEAMS_CREATED - Teams are finalized
- MATCH_CANCELLED - Match is cancelled instead
- SUBSTITUTION - Player substitution during match
Database Storage Example
def store_match_result(data):
import sqlite3
from datetime import datetime
conn = sqlite3.connect('matches.db')
cursor = conn.cursor()
cursor.execute('''
INSERT INTO match_results
(queue, guild, winning_team_index, completed_at, data)
VALUES (?, ?, ?, ?, ?)
''', (
data['queue'],
data['guild'],
data['winning_team_index'],
datetime.now(),
json.dumps(data)
))
conn.commit()
conn.close()