Skip to content

Web DashboardStats

Domekologe edited this page Jun 30, 2026 · 1 revision

Web DashboardStats

🌐 English · Deutsch

WebDashboardStats silently records per-guild statistics — messages, voice, members, presence, game activity, invites and command usage — into time-bucketed storage, and exposes them as read methods for the WebDashboard gateway. It has no user-facing commands: it runs entirely from Discord listeners and a background loop, and the data is visualised on the dashboard's /stats page. Bots are ignored for messages, voice and activity. Author: pd-codes · requires Red 3.5.0+ · Status: Release.

Screenshot: dashboard /stats page with charts

Installation

[p]repo add PDC_Redbot_Cogs https://github.com/pd-codes/PDC_Redbot_Cogs
[p]cog install PDC_Redbot_Cogs pdc_webdashboard_stats
[p]load pdc_webdashboard_stats

[p] is your bot's prefix. See Installation for the full Downloader walkthrough. The charts only appear once the WebDashboard cog and the PDC_Redbot_Webapp frontend are running.

Note: this cog was formerly named WebServerStats (web_serverstats). Existing statistics are preserved across the rename — the cog pins its original Config namespace, so no data is lost when you upgrade.

Intents: enable the Presence and Server Members intents in the Discord Developer Portal for complete status and activity data. Without them member presence and game activity stay empty.

What it tracks

Data is written into daily buckets (key YYYY-MM-DD, UTC) per guild; presence is sampled separately. The cog listens to Discord events and a periodic snapshot loop:

Metric Source Bucket / granularity
Messages (total) on_message daily (days.messages)
Messages per channel on_message daily, per channel ID (msg_channels)
Messages per member on_message daily, per member ID (msg_members)
Member joins / leaves on_member_join / on_member_remove daily (days.joins, days.leaves)
Member count snapshot loop daily, last value of the day (days.members)
Voice minutes (total) on_voice_state_update daily (days.voice_minutes)
Voice minutes per channel voice sessions daily, per channel ID (voice_channels)
Voice minutes per member voice sessions daily, per member ID (voice_members)
Presence status (online/idle/dnd/offline) snapshot loop sampled every 30 min (status_samples)
Game activity (minutes per game) snapshot loop daily, per game name (activity)
Invite tracking (which code, by whom) on_invite_create + join diffing per-code uses, daily joins, log of last 500, per-inviter totals
Command usage on_command_completion daily, per command name (commands)
Command errors on_command_error daily, per command name (command_errors)

Voice is measured by pairing on_voice_state_update channel changes: a running session is opened when a non-bot joins a channel and closed (its minutes recorded) when they leave or switch. Open sessions are re-captured on on_ready after a restart so counting survives reloads, and flushed best-effort on unload.

Invites are tracked by comparing each invite's stored uses against the live list when a member joins, attributing the join to the code whose use count went up — and to the inviting member.

Performance & retention

  • In-memory buffering: messages and command usage are counted in RAM and flushed to config every 60 seconds (one batched write per guild instead of several writes per message).
  • Presence sampling: the snapshot loop runs every 30 minutes (member count, status counts, game activity).
  • Retention: daily buckets are pruned after 400 days; presence samples are capped at roughly 60 days; the invite log keeps the last 500 entries.

Configuration

The cog stores config per guild. There is a single toggle:

Key Default Meaning
enabled true When false, no tracking happens for that guild (checked on every listener and snapshot; cached in memory for the message hot path).

There are no chat commands; the toggle is set through the dashboard (or via Red's config tooling). All other keys (days, msg_channels, msg_members, voice_channels, voice_members, status_samples, activity, invites, invite_daily, invite_logs, invite_members, commands, command_errors) are internal data stores, not settings.

Dashboard integration

The cog does not open its own gateway connection. Instead it provides public async read methods that the WebDashboard gateway calls to feed the /stats page. Each takes the guild and a days range and returns chart-ready data (labels + series + KPIs + "top" lists):

Method Powers
stats_overview(guild, days=30) Member/join/leave trend lines plus 7-day KPIs (members, joins, leaves, messages, voice hours).
stats_messages(guild, days=30) Daily message series, totals, unique members/channels, top members and top channels.
stats_voice(guild, days=30) Daily voice-hours series, totals, top members and top channels.
stats_status(guild, days=14) Presence samples (online/idle/dnd/offline) within the range.
stats_invites(guild, days=14) Per-code daily series, top invites, recent join log, top inviting members.
stats_activity(guild, days=30) Top games by total minutes played.
stats_commands(guild, days=30) Daily command-usage series, total/error counts, unique commands, top commands with error counts.
stats_member_drilldown(guild, member_id, days=30) Messages and voice hours for a single member, with a picker of available members.
stats_channel_drilldown(guild, channel_id, days=30) Messages and voice hours for a single channel, with a picker of available channels.

The days argument is clamped between 1 and the 400-day retention. Charts are rendered entirely in the web app.

Related pages

Clone this wiki locally