Skip to Content
MineDuels

Webhooks

webhook.yml on the backends and the proxy: messages when a server drains, is empty or stops.

Both the backend plugin and the Velocity plugin read a file named webhook.yml. Each posts to a webhook URL, for example a Discord channel, so you know when a restart is safe.

WhereFile
Backendplugins/MineDuels/webhook.yml
Proxyplugins/mineduels/webhook.yml

Each file is written with defaults on the first start. enabled is false until you turn it on.

Backend webhook.yml

config-version: 1
enabled: true
url: "https://discord.com/api/webhooks/123456789/abcdef"
format: discord
username: "MineDuels"
avatar-url: ""
mention: "<@&123456789012345678>"
server-label: ""
stable-seconds: 15
progress-minutes: 0
timeout-seconds: 5
retries: 2
events:
  drain-started: true
  drain-cancelled: true
  drain-progress: true
  drain-empty: true
  server-started: true
  server-stopping: true
KeyDefaultMeaning
enabledfalseTurns webhooks on.
urlemptyAn https address. Webhooks stay off with a warning when it is empty or not https.
formatdiscorddiscord sends an embed. json sends plain JSON for your own tools.
username, avatar-urlMineDuels, emptySender name and picture in Discord.
mentionemptyPinged on every message. Only role and user pings such as <@&123> or <@456> are allowed.
server-labelemptyThe name in the message. Empty uses cross-server.server-name, or server on a standalone server.
stable-seconds15The server must stay empty this long before drain-empty is sent. Range 1 to 600.
progress-minutes0While draining and not yet empty, post the remaining players every this many minutes. 0 is off.
timeout-seconds5Time allowed for one request. Range 1 to 30.
retries2Tries after a failure. Range 0 to 5.
events.<name>truefalse turns one message off.

Backend events

EventSent when
drain-started/md drain start. Lists players, running matches and pending assignments.
drain-cancelled/md drain stop.
drain-progressEvery progress-minutes while draining and not empty.
drain-emptyNo players, no running matches and no pending assignments for stable-seconds. Once per drain.
server-startedThe plugin finished starting.
server-stoppingThe server is stopping. Sent before the plugin closes, waiting at most 3 seconds.

Proxy webhook.yml

config-version: 1
enabled: true
url: "https://discord.com/api/webhooks/123456789/abcdef"
format: discord
username: "MineDuels Proxy"
mention: ""
server-label: "proxy-eu"
stable-seconds: 15
events:
  proxy-drain-started: true
  proxy-drain-cancelled: true
  proxy-empty: true
  network-drained: true
  backend-lost: true
  backend-recovered: true
  gate-redis-down: true

The keys are the same as on the backend, without progress-minutes. An empty server-label uses proxy-name.

Proxy events

EventSent when
proxy-drain-started/mdproxy drain start.
proxy-drain-cancelled/mdproxy drain stop.
proxy-emptyA draining proxy has no connected players for stable-seconds.
network-drainedEvery draining backend has no players and no running matches for stable-seconds.
backend-lostA backend stopped sending heartbeats. Not sent for a backend that was draining.
backend-recoveredThat backend sends heartbeats again.
gate-redis-downThe proxy hears nothing from Redis. The gate then follows gate.on-redis-down.

The backends report their own empty state and the proxy does not repeat it, so one restart gives one drain-empty.

Reload

WhereCommand
Backend/md reload reads webhook.yml again. A broken file keeps the previous settings.
Proxy/mdproxy reload

Examples

Discord with a role ping

enabled: true
url: "https://discord.com/api/webhooks/123456789/abcdef"
format: discord
mention: "<@&123456789012345678>"

The message title is game-2: Empty, safe to restart and the role is pinged.

Only the messages you want

events:
  drain-started: false
  drain-cancelled: false
  drain-progress: false
  drain-empty: true
  server-started: false
  server-stopping: false

Progress every 5 minutes on a busy server

progress-minutes: 5
stable-seconds: 30

JSON for your own tools

format: json
url: "https://hooks.example.com/mineduels"

Each message is one POST with this body:

{
  "event": "drain-empty",
  "server": "game-2",
  "title": "Empty, safe to restart",
  "detail": "No players, running matches or pending assignments for 15s.",
  "time": "2026-11-22T21:40:12.318Z"
}

Restart the server when it is empty

A small receiver that restarts a Pterodactyl server on drain-empty. format is json:

from http.server import BaseHTTPRequestHandler, HTTPServer
import json, urllib.request

SERVERS = {"game-2": "a01a22ef"}
PANEL = "https://panel.example.com"
KEY = "ptlc_your_client_api_key"

class Hook(BaseHTTPRequestHandler):
    def do_POST(self):
        body = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
        self.send_response(204)
        self.end_headers()
        if body["event"] != "drain-empty" or body["server"] not in SERVERS:
            return
        req = urllib.request.Request(
            f"{PANEL}/api/client/servers/{SERVERS[body['server']]}/power",
            data=json.dumps({"signal": "restart"}).encode(),
            headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"},
        )
        urllib.request.urlopen(req)

HTTPServer(("0.0.0.0", 8080), Hook).serve_forever()

Behaviour

ThingBehaviour
Where requests runOn their own thread. A slow or broken webhook never slows the game.
QueueUp to 50 messages wait. The oldest are dropped first.
RetriesA failed request is retried with a growing delay. Discord rate limit answers (429) are honoured, up to 10 seconds.
ErrorsLogged at most once a minute, with the host only. The URL is never logged.
PingsText from players or reasons cannot ping anyone. Only mention can.

On this page