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
| Field | Type | Description |
|---|---|---|
action | string | Always "REGISTER_PLAYER" |
queue | string | The name/identifier of the queue |
channel | string | Discord channel ID where the event occurred |
guild | string | Discord guild (server) ID |
account | string | In-game account name being registered |
player | string | Discord username |
player_id | string | Discord user ID |
Expected Response
Your webhook endpoint must return a JSON response with a status code.
Success Response (200 OK)
{
"success": true,
"message": "Account registered successfully"
}
Error Response (Non-200 Status)
{
"success": false,
"error": "Account already registered to another user"
}
info
The message or error field content will be displayed to the user in Discord.
When This Event Fires
This webhook is sent when:
- A player uses the
/registercommand - The queue requires account registration
- A player links their in-game account
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({
"success": False,
"error": 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({
"success": False,
"error": "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({
"success": False,
"error": f"You already have account '{existing_account}' registered"
}), 400
# Register the account
register_account(discord_id, account)
return jsonify({
"success": True,
"message": f"Successfully registered account: {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({
"success": False,
"error": message
}), 404
# Continue with registration...
register_account(data['player_id'], account)
return jsonify({
"success": True,
"message": f"Account {account} verified and registered!"
}), 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({
"success": False,
"error": "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({
"success": True,
"message": "Registration successful!"
}), 200
Response Requirements
- Respond within 10 seconds - Requests timeout after 10 seconds
- Return proper status codes:
200for success400for validation errors404for not found500for server errors
- Include descriptive messages - Users will see your error messages
- 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
- Validate account ownership - Require proof of account ownership
- Rate limit registrations - Prevent abuse
- Sanitize input - Clean the
accountfield to prevent injection - 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({
"success": False,
"error": "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"
}'
Related Events
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 with async processing
def handle_registration(data):
# Quick validation only
if not is_valid_format(data['account']):
return jsonify({"success": False, "error": "Invalid format"}), 400
# Defer detailed validation
# (You might need a separate verification step)
return jsonify({"success": True, "message": "Registration pending verification"}), 200