/DiscordGuildStats

Displays Discord Guild statistics for members, bots, roles, channels, assigned member roles, invites, bans, reactions, stickers, and scheduled events counts.

Primary LanguageTypeScript

Node.js CI ts GitHub Release GitHub Contributors Discord

Discord Guild Statistics Bot

Displays Discord Guild statistics for members, bots, roles, channels, assigned member roles, invites, bans, reactions, stickers, and scheduled events counts.

This is a rewrite in Typescript of my original GuildStats project.

Features

  • Guild statistics for:
    • Total members count
    • Total bots count
    • Total roles count
    • Total channels count
    • Total invites count
    • Total bans count
    • Total reactions count
    • Total stickers count
    • Total scheduled events count
    • Assigned member roles count
  • Updates at an interval every specified minutes or relies solely on Discord event triggers
  • Supports multiple Discord servers
  • Log level filtering
  • Export/dump of specified guild statistics
  • Locales to specify custom naming of channels

Preview

Image Preview

Prerequisites

Installation

  1. Clone repository: git clone https://github.com/versx/DiscordGuildStats
  2. Install packages: npm install
  3. Copy example config: cp src/config.example.json src/config.json
  4. Fill out config options.
  5. Build project in root folder: npm run build
  6. Run: npm run start

Updating

  1. Pull latest changes in root folder git pull
  2. Build project in root folder: npm run build
  3. Run npm run start

Configuration

{
  // Discord Guild Statistics
  "dumpStatistics": {
    // Determines whether to dump Discord guild statistics every interval.
    "enabled": false,
    // The statistics data to include in the dumps.
    "data": [
      "members", "bots", "roles", "channels",
      "invites", "bans", "reactions", "stickers",
      "scheduledEvents", "memberRoles"
    ],
    // File name of the statistics dump. Leaving the `fileName` blank/empty
    // will default to the date. (i.e. `2023-09-15.csv`)
    "fileName": "dumps.csv"
  },
  // Logging configuration.
  "logs": {
    // Log level to filter logs by.
    // Available values:
    //  - trace (log everything)
    //  - debug (only log debug, info, warnings, and errors)
    //  - info (only log info, warnings, and errors)
    //  - warn (only log warnings and errors)
    //  - error (only log errors)
    //  - none (disable logging)
    "level": "info",
    // Log color dictionary.
    "colors": {
      // Normal text
      "text": "#ffffff",
      // Variables
      "variable": "#ff624d",
      // Dates
      "date": "#4287f5",
      // Errors
      "error": "#ff0000"
    }
  },
  // Delay between each channel update in milliseconds.
  "sleepBetweenChannels": 250,
  // Delay between each guild update in milliseconds.
  "sleepBetweenGuilds": 3000,
  // Discord bot activity status.
  "status": null,
  // Discord bot token.
  "token": "<DISCORD_BOT_TOKEN>",
  // Update interval in minutes. Specify `0` will only rely on
  // Discord events to check for Discord guild changes.
  "updateIntervalM": 15,
  // Discord servers to include for updating statistics.
  "servers": {
    // Discord guild ID
    "<DISCORD_GUILD1_ID>": {
      // Descriptive name for Discord guild. (not actually used, just for your reference.)
      "name": "<DESCRIPTIVE_NAME>",
      // Channel ID for member counts.
      "memberCountChannelId": "00000000000001",
      // Channel ID for bot counts.
      "botCountChannelId": "00000000000002",
      // Channel ID for role counts.
      "roleCountChannelId": "00000000000003",
      // Channel ID for channel counts.
      "channelCountChannelId": "00000000000004",
      // Channel ID for invite counts.
      "inviteCountChannelId": "00000000000005",
      // Channel ID for ban counts.
      "banCountChannelId": "00000000000006",
      // Channel ID for reaction/emoji counts.
      "reactionCountChannelId": "00000000000007",
      // Channel ID for sticker counts.
      "stickerCountChannelId": "00000000000008",
      // Channel ID for scheduled event counts.
      "eventCountChannelId": "00000000000009",
      // Roles assigned to Discord members.
      "memberRoles": {
        // Channel ID for specific roles statistic count.
        "<DISCORD_ROLE_CHANNEL1_ID>": {
          // Role IDs to include in statistic.
          "roleIds": ["<DISCORD_ROLE1_ID>"],
          // Text/name of channel for role statistic.
          "text": "Administators"
        },
        // Channel ID for specific roles statistic count.
        "<DISCORD_ROLE_CHANNEL2_ID>": {
          // Role IDs to include in statistic.
          "roleIds": ["<DISCORD_ROLE2_ID>"],
          // Text/name of channel for role statistic.
          "text": "Moderators"
        },
        // Channel ID for specific roles statistic count.
        "<DISCORD_ROLE_CHANNEL3_ID>": {
          // Role IDs to include in statistic.
          "roleIds": ["<DISCORD_ROLE3_ID>"],
          // Text/name of channel for role statistic.
          "text": "Supporters"
        }
      }
    }
  }
}

Notes

  • Not specifying a channel ID (i.e. null) for a statistics count in the config will omit that statistic from being updated.
  • Not specifying a file name for the guild statistics dump will use the date (i.e. 2023-09-15.csv) by default.
  • Specifying 0 for updateIntervalM will disable the interval timer and only rely on Discord events to check for Discord guild changes.