A zero-config, real-time analytics dashboard for discord.py bots with MongoDB support.
Project description
📊 Discord Insight
Discord Insight is a zero-config, real-time analytics dashboard for discord.py bots. Drop one line of code into your bot, and instantly get a beautiful, local web dashboard tracking your bot's growth, errors, and performance with MongoDB Atlas persistence.
✨ Features
- 🚀 Zero-Configuration: No massive setups. Pass your bot object and MongoDB URI, and it just works.
- 📈 Real-Time Dashboard: A sleek, responsive (Dark/Light mode) web UI powered by Tailwind CSS and Chart.js.
- 👥 Daily Active Users (DAU): Accurately track how many unique users interact with your bot daily without leaking memory.
- 🔥 Command Heatmap & Distribution: Know exactly when and how your commands are being used.
- 🛡️ Live Error Tracebacks: Catch exceptions as they happen. View detailed error tracebacks right from your browser.
- 💻 System Metrics: Monitor your host machine's CPU usage, RAM utilization, and Discord API latency (Ping).
- ☁️ MongoDB Persistence: All stats survive bot restarts and host migrations thanks to MongoDB Atlas integration.
📦 Installation
Install discord-insight and python-dotenv (for secure credentials) via pip:
pip install discord-insight python-dotenv
Note: Ensure you are using Python 3.8+ and have discord.py installed.
🚀 Quick Start
- Setup your .env file
Never hardcode your secrets! Create a .env file in your bot's root directory:
DISCORD_TOKEN=your_bot_token_here
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority
- Add Insight to your Bot
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
from discord_insight import Insight
# Load secrets from .env
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
MONGO_URL = os.getenv("MONGO_URI")
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
# Initialize Discord Insight (This one line does all the heavy lifting!)
Insight(
bot=bot,
mongo_uri=MONGO_URL,
dashboard=True,
host="127.0.0.1",
port=8080,
password="admin" # Protects your dashboard
)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}!")
print("Dashboard live at: http://127.0.0.1:8080")
@bot.command()
async def ping(ctx):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")
bot.run(TOKEN)
- View your Analytics
Run your bot, then open your web browser and navigate to:
(Login with the username admin and the password you set in the initialization).
⚙️ Configuration Options
The Insight class accepts the following parameters:
Parameter Type Default Description bot discord.Client Required Your discord.py bot instance. mongo_uri str Required Your MongoDB Atlas connection string. dashboard bool True Whether to launch the local web dashboard. host str "127.0.0.1" The IP address to host the dashboard on. Use "0.0.0.0" for external access. port int 8080 The port for the web dashboard. password str None Set a password to lock the dashboard behind Basic Auth.
🛠️ Troubleshooting Android/Termux Users
If you are hosting your bot on Termux (Android) and get a PermissionError: /etc/resolv.conf, you need to configure your DNS resolver before importing Insight. Add this to the very top of your main file:
import dns.resolver
dns.resolver.default_resolver = dns.resolver.Resolver(configure=False)
dns.resolver.default_resolver.nameservers = ['8.8.8.8', '8.8.4.4']
🤝 Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
📝 License
This project is MIT licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file discord_insight-0.0.1.tar.gz.
File metadata
- Download URL: discord_insight-0.0.1.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2e5ab3bb172cbc1a434999c3176b5a668c216537a9a6b4501a90a9887b885ca
|
|
| MD5 |
6d5f0e243811844eda6a2c2d019c1372
|
|
| BLAKE2b-256 |
271a76b2b7e886b8afe80a14f397b226e2aeb3a9d90f8ec16874d24283e102d9
|
Provenance
The following attestation bundles were made for discord_insight-0.0.1.tar.gz:
Publisher:
publish.yml on rugved-danej/discord-insight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
discord_insight-0.0.1.tar.gz -
Subject digest:
e2e5ab3bb172cbc1a434999c3176b5a668c216537a9a6b4501a90a9887b885ca - Sigstore transparency entry: 1282899185
- Sigstore integration time:
-
Permalink:
rugved-danej/discord-insight@d737a0a8a82c0e9a4795427a576ba53491dd9e2b -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/rugved-danej
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d737a0a8a82c0e9a4795427a576ba53491dd9e2b -
Trigger Event:
release
-
Statement type:
File details
Details for the file discord_insight-0.0.1-py3-none-any.whl.
File metadata
- Download URL: discord_insight-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99aa5659765e19ee56565b289112ce9e630929cbc64f85f0929fe2d695ae9106
|
|
| MD5 |
cc54dcb62effb7178557cde2b426eb50
|
|
| BLAKE2b-256 |
25afd9656a34f8c98700374721cb54a04cde0eff32735f2a4c2f54a4f586f7bd
|
Provenance
The following attestation bundles were made for discord_insight-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on rugved-danej/discord-insight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
discord_insight-0.0.1-py3-none-any.whl -
Subject digest:
99aa5659765e19ee56565b289112ce9e630929cbc64f85f0929fe2d695ae9106 - Sigstore transparency entry: 1282899188
- Sigstore integration time:
-
Permalink:
rugved-danej/discord-insight@d737a0a8a82c0e9a4795427a576ba53491dd9e2b -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/rugved-danej
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d737a0a8a82c0e9a4795427a576ba53491dd9e2b -
Trigger Event:
release
-
Statement type: