Skip to main content

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​

FieldTypeDescription
actionstringAlways "MATCH_COMPLETED"
queuestringThe name/identifier of the queue
channelstringDiscord channel ID where the event occurred
guildstringDiscord guild (server) ID
teamsPlayer[][]2D array of teams
winning_team_indexnumberIndex of the winning team (0, 1, etc.). Equal to the number of teams (len(teams)) for a tie, and -1 if the match was cancelled
match_numbernumberThe match number

When This Event Fires​

This webhook is sent when:

  • A winner vote completes
  • Staff set a winner, tie or cancellation for a match in progress (/outcome selectwinner, /outcome tie, /outcome cancel)
  • A /cancel vote passes for a match in progress
  • An automated result is determined

It is not sent for matches without an outcome (single-team queues, or /message winnermessage results set to Disabled), and changing the result of a match that has already finished does not send it again.

tip

Use winning_team_index to identify the winning team: teams[winning_team_index]. Check for a tie (winning_team_index == len(teams)) and a cancellation (winning_team_index == -1) first, since neither has a winning team.

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​

  1. MATCH_STARTED - Match validation begins
  2. TEAMS_CREATED - Teams are formed
  3. MATCH_COMPLETED ← You are here

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()