Skip to main content

REGISTER_PLAYER

Interactive Webhook

This is an interactive webhook that expects a response from your endpoint. The registration will succeed or fail based on your response.

Triggered when a player registers their in-game account using the /register command.

Example Payload​

{
"action": "REGISTER_PLAYER",
"queue": "valorant",
"channel": "1234567890123456789",
"guild": "9876543210987654321",
"account": "PlayerGameAccount",
"player": "Player1#1234",
"player_id": "111222333444555666"
}

Payload Fields​

FieldTypeDescription
actionstringAlways "REGISTER_PLAYER"
queuestringThe name/identifier of the queue
channelstringDiscord channel ID where the event occurred
guildstringDiscord guild (server) ID
accountstringIn-game account name being registered
playerstringDiscord username
player_idstringDiscord user ID

Expected Response​

Your webhook endpoint must respond with a JSON body (Content-Type: application/json), and only status 200 counts as success.

Success Response (200 OK)​

{
"rating": 1000
}

The rating key is required: it becomes the player's MMR in this queue, and the account they entered is saved as their IGN. The player sees Your rating has been registered as <rating> from <account>. A 200 response without rating fails the registration with "No rating has been specified for you!".

Error Response (Non-200 Status)​

{
"detail": "Account already registered to another user"
}
info

On a non-200 response, the detail field is shown to the player in Discord (or "No response" if it is missing). A response that isn't valid JSON, or no response within 10 seconds, shows a generic error instead.

When This Event Fires​

This webhook is sent when:

  • The queue's registration mode is Custom API (/requireregister mode: Custom API), and
  • A player who isn't registered in that queue yet runs /register and submits their account in the form

If the queue has no webhook set, /register tells the player "Your admin must configure the webhook!" and nothing is sent.

Use Cases​

  • Validate in-game accounts against an external API
  • Check if account exists in your game database
  • Prevent duplicate registrations
  • Link Discord users to game accounts
  • Verify account ownership
  • Enforce account restrictions (bans, age, etc.)

Implementation Example​

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/webhook', methods=['POST'])
def handle_webhook():
data = request.json

if data['action'] == 'REGISTER_PLAYER':
return handle_registration(data)

return jsonify({"success": True}), 200

def handle_registration(data):
account = data['account']
discord_id = data['player_id']

# Check if account exists in your system
if not account_exists(account):
return jsonify({
"detail": f"Account '{account}' not found in our system"
}), 404

# Check if account is already registered
existing_user = get_registered_user(account)
if existing_user and existing_user != discord_id:
return jsonify({
"detail": "This account is already registered to another user"
}), 400

# Check if user already has an account registered
existing_account = get_user_account(discord_id)
if existing_account:
return jsonify({
"detail": f"You already have account '{existing_account}' registered"
}), 400

# Register the account and return the rating they should start with
register_account(discord_id, account)

return jsonify({
"rating": get_starting_rating(account)
}), 200

Validation Examples​

Validate Against External Game API​

import requests

def validate_game_account(account_name):
# Example: Validate against Riot Games API
api_key = "YOUR_API_KEY"
response = requests.get(
f"https://api.riotgames.com/lol/summoner/v4/summoners/by-name/{account_name}",
headers={"X-Riot-Token": api_key}
)

if response.status_code == 200:
return True, "Account found"
elif response.status_code == 404:
return False, "Account not found"
else:
return False, "Unable to verify account"

def handle_registration(data):
account = data['account']

is_valid, message = validate_game_account(account)

if not is_valid:
return jsonify({
"detail": message
}), 404

# Continue with registration...
register_account(data['player_id'], account)

return jsonify({
"rating": get_starting_rating(account)
}), 200

Database Lookup​

import sqlite3

def handle_registration(data):
account = data['account']
discord_id = data['player_id']

conn = sqlite3.connect('accounts.db')
cursor = conn.cursor()

# Check for duplicate account registration
cursor.execute(
'SELECT discord_id FROM registrations WHERE game_account = ?',
(account,)
)
existing = cursor.fetchone()

if existing and existing[0] != discord_id:
conn.close()
return jsonify({
"detail": "Account already registered"
}), 400

# Register account
cursor.execute(
'INSERT OR REPLACE INTO registrations (discord_id, game_account, registered_at) VALUES (?, ?, ?)',
(discord_id, account, time.time())
)

conn.commit()
conn.close()

return jsonify({
"rating": 1000 # the rating this player should start with
}), 200

Response Requirements​

  1. Respond within 10 seconds - Requests timeout after 10 seconds
  2. Return proper status codes:
    • 200 for success
    • 400 for validation errors
    • 404 for not found
    • 500 for server errors
  3. Include descriptive messages - Users see the detail field of your error responses
  4. Handle network failures gracefully

Error Messages Best Practices​

Good error messages:

  • ✅ "Account 'PlayerName' not found in our database"
  • ✅ "This account is already registered to another user"
  • ✅ "Your account must be level 30 or higher to register"

Poor error messages:

  • ❌ "Error"
  • ❌ "Invalid request"
  • ❌ "Database error"

Security Considerations​

  1. Validate account ownership - Require proof of account ownership
  2. Rate limit registrations - Prevent abuse
  3. Sanitize input - Clean the account field to prevent injection
  4. Log all attempts - Track registration attempts for security
import re

def sanitize_account_name(account):
# Remove special characters, allow only alphanumeric and basic symbols
return re.sub(r'[^a-zA-Z0-9_\-\s]', '', account)

def handle_registration(data):
account = sanitize_account_name(data['account'])

# Enforce length limits
if len(account) < 3 or len(account) > 30:
return jsonify({
"detail": "Account name must be between 3 and 30 characters"
}), 400

# Continue with registration...

Testing Your Implementation​

Use curl to test your registration endpoint:

curl -X POST https://your-domain.com/webhook \
-H "Content-Type: application/json" \
-H "Authorization: your-token" \
-d '{
"action": "REGISTER_PLAYER",
"queue": "valorant",
"channel": "1234567890",
"guild": "9876543210",
"account": "TestAccount",
"player": "TestUser#1234",
"player_id": "111222333444"
}'

Unlike other webhook events, REGISTER_PLAYER requires immediate processing and a response. Other events are fire-and-forget notifications.

Common Issues​

Timeout Errors​

If your endpoint takes too long to respond:

# BAD: Slow synchronous processing
def handle_registration(data):
result = slow_external_api_call(data['account']) # Takes 15 seconds
return jsonify(result)

# GOOD: Quick response from data you already have
def handle_registration(data):
# Quick validation only
if not is_valid_format(data['account']):
return jsonify({"detail": "Invalid format"}), 400

# Return a rating you can look up quickly (e.g. from your own cache).
# The bot needs it in this response to complete the registration.
return jsonify({"rating": get_cached_rating(data['account'])}), 200