Add Metrics Collection (gamify discord????) #20

Open
opened 2026-02-02 15:16:13 -05:00 by jared · 0 comments
Owner

from collections import Counter
from datetime import datetime

class MetricsCollector:
def init(self):
self.command_counts = Counter()
self.error_counts = Counter()
self.start_time = datetime.now()

def record_command(self, command_name: str):
    self.command_counts[command_name] += 1

def get_stats(self) -> dict:
    uptime = datetime.now() - self.start_time
    return {
        "uptime_seconds": uptime.total_seconds(),
        "commands_executed": sum(self.command_counts.values()),
        "top_commands": self.command_counts.most_common(5),
        "error_count": sum(self.error_counts.values())
    }

metrics = MetricsCollector()

from collections import Counter from datetime import datetime class MetricsCollector: def __init__(self): self.command_counts = Counter() self.error_counts = Counter() self.start_time = datetime.now() def record_command(self, command_name: str): self.command_counts[command_name] += 1 def get_stats(self) -> dict: uptime = datetime.now() - self.start_time return { "uptime_seconds": uptime.total_seconds(), "commands_executed": sum(self.command_counts.values()), "top_commands": self.command_counts.most_common(5), "error_count": sum(self.error_counts.values()) } metrics = MetricsCollector()
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/discordBot#20