BarbaricDev
Tool Control AI

Control AI Discord Bot

Built for Control AI

A Discord bot for tracking server statistics and member activity for the Control AI Discord server. It collects daily metrics, maintains a persistent user database, and automatically exports data to Google Sheets.

Features

  • Daily statistics tracking — counts messages, unique chatters, members joining/leaving, and peak online member count each day
  • Invite link tracking — detects which invite link each new member used when joining
  • User database — persists per-user data including join/leave dates, message timestamps, and the invite link used
  • Inactivity detection — identify members who haven’t sent a message in a configurable number of days
  • Google Sheets export — automatically writes daily stats and per-invite-link stats to a Google Spreadsheet at midnight
  • Automatic daily backups — saves the user database to db_backups/ at the end of each day
  • Error alerting — pings the bot developer via Discord if any scheduled task throws an exception

Scheduled Tasks

  • Midnight task — writes stats to Google Sheets, posts a summary to the stat log channel, saves and backs up the user database, then resets all daily counters
  • Online member check (every 10 minutes) — updates the peak concurrent online member count for the day

Admin Commands

All commands are prefixed with ! and are restricted to users with a mod role.

Command Description
!statsPrint today’s stats so far to the current channel
!inactive <days>List members who have not sent a message in the past <days> days
!getuniquechatters <YYYY-MM-DD> <YYYY-MM-DD>Count unique chatters between two dates
!inviteGenerate a new permanent invite link in the current channel
!setinvite <user_id> <invite_code>Manually set the invite code a user joined with
!filldbAdd any server members missing from the user database (invite link will be unknown)
!writeuserdbManually save the user database to disk
!loaduserdbReload the user database from disk
!backupTrigger an immediate database save
!debugwriteForce-write today’s (incomplete) stats to the Google Spreadsheet
!helpShow the command list

Tech Stack

Python discord.py Discord API Google Sheets API gspread JSON