commands.stats_commands module
User Statistics Collection Commands
This module provides Discord slash commands for collecting and managing user message statistics from Discord channels.
- class commands.stats_commands.StatsCollector(bot)[source]
Bases:
object
Service class for collecting user message statistics.
- async collect_user_stats(guild, target_user=None, channels=None, days_back=None, job_id=None)[source]
Collect message statistics for user(s) in specified channels.
- Parameters:
guild (
Guild
) – Discord guild to scantarget_user (
Member
) – Specific user to collect stats for (None = all users)channels (
list
[TextChannel
]) – List of channels to scan (None = all text channels)days_back (
int
) – Number of days to look back (None = all time)job_id (
str
) – Unique job identifier for progress tracking
- Returns:
Collection results with statistics
- Return type:
- get_active_guild_job(guild_id)[source]
Check if there’s an active collection job for a specific guild.
- Return type:
- async collect_user_stats_streaming(guild, target_user=None, channels=None, days_back=None, job_id=None)[source]
Collect message statistics using streaming approach to minimize memory usage.
This method processes messages one by one and writes statistics to the database immediately, avoiding accumulation of large amounts of data in memory.
- Parameters:
guild (
Guild
) – Discord guild to scantarget_user (
Member
) – Specific user to collect stats for (None = all users)channels (
list
[TextChannel
]) – List of channels to scan (None = all text channels)days_back (
int
) – Number of days to look back (None = all time)job_id (
str
) – Unique job identifier for progress tracking
- Returns:
Collection summary (minimal data kept in memory)
- Return type: