PlayitStatus
Checks the status of a playit.gg tunnel via the public status page and posts changes to a Discord channel.
This cog does not run a background monitor. The manifest and older documentation describe polling every ten seconds and alerting when the tunnel goes down. The code contains no loop. Status is fetched only when a command runs. Read the "Actual behavior" section before relying on it for outage alerts.
Requirements
- Manage Server or a Red admin role for every command, applied on the group.
- The bot must be able to send messages and embed links in the target channel.
- The channel must be visible to the bot when the command runs, because the channel is resolved from the cache with
bot.get_channel.
Commands
| Command | Arguments | Behavior |
|---|---|---|
[p]playit channel |
<channel_id> |
Saves the alert channel and posts the current state |
[p]playit status |
none | Fetches the API and posts only changed states |
channel
[p]playit channel 123456789012345678
Takes a numeric channel ID. A mention is not accepted. The ID must resolve from the bot's channel cache, which normally requires the bot to be in the guild and the channel to be a text channel it can see.
The command saves the ID, fetches the monitor list, and posts status for any monitor that is not up. It then confirms with "Monitoring set to {channel}. Status posted." even when the post contained nothing. If the fetch fails, the channel is still saved and the reply says the status fetch failed.
status
[p]playit status
Requires a configured channel. Fetches the monitor list, compares each monitor with the last stored state, and posts an embed for each monitor that changed. The reply is "No changes. All services stable." when nothing changed. This command posts to the configured channel, not necessarily the channel where it was invoked.
Actual behavior of the status check
The API URL is fixed:
https://status.playit.gg/api/getMonitorList/AxwIw5PSiW
It returns a JSON object with a data list. Each monitor has a name and a statusClass. A monitor counts as up when statusClass equals success; every other value counts as down.
The stored state is a map of monitor name to boolean. A monitor missing from the map is treated as previously up, so a monitor that is already down when first checked produces a DOWN alert.
For each monitor:
- Up now and up before: skipped.
- Down now and up before: red embed titled "playit.gg DOWN" with a description naming the monitor.
- Up now and down before: green embed titled "playit.gg UP".
- Down now and down before: skipped.
The channel command calls the same routine with changed_only=False. That flag only skips unchanged monitors when it is true, and unchanged means both states are up. A monitor that stays down is skipped in both modes because the up/down comparison produces no embed and the loop continues.
Limitations
- No scheduled checks. Automatic outage alerts do not happen. The only way to get a fresh alert is to run
[p]playit statuson a schedule from outside the bot, for example a cron job driving a webhook that triggers the command, or by adding atasks.loopto the source. - The
aiohttpsession created byinit_sessionis never closed. There is nocog_unload, so a reload leaks the session until the process ends. - API failures are swallowed.
fetch_statusreturns an empty list for every exception and for any non-200 response, and the command reports a generic fetch failure. - Monitor names are used as dictionary keys, so two monitors with the same name share one state.
- Embeds use naive UTC timestamps, which Discord interprets as UTC.
- The monitor list ID is tied to one playit.gg account. A different account needs a different list ID, which requires editing the source.
Stored data
Global config under identifier 1234567890:
| Key | Type | Default |
|---|---|---|
channel_id |
int or null | null |
last_status |
map of string to bool | {} |
red_delete_data_for_user does nothing. There is no per-guild configuration, so one channel serves the whole bot.
Scrapyard Cogworks
Cogs