A webhook and request based discord.py extension for making a bot dashboard.
Project description
discord-ext-dashboard
A webhook and request based discord.py extension for making a bot dashboard.
Installation
pip install -U discord-ext-dashboard
# Or
pip install --upgrade discord-ext-dashboard
Usage
Prerequisites
Before you get started, you will need a few things:
- A webhook in secret channel (if anyone has access, they will be able to mess things up)
- A properly hosted discord.py bot
And then you're ready to get started!
Examples
Bot
import discord
from discord.ext import commands
from discord.ext.dashboard import Dashboard
bot = commands.Bot(command_prefix="!")
bot_dashboard = Dashboard(bot,
"secret_key",
"https://your-bot-website.com/dashboard"
)
@bot.event
async def on_ready():
print(f"Bot is online as {bot.user}")
@bot.event
async def on_message(message):
await bot_dashboard.process_request(message)
@bot_dashboard.route
async def guild_count(data):
return len(bot.guilds)
@bot_dashboard.route
async def member_count(data):
return await bot.fetch_guild(data["guild_id"]).member_count
bot.run("your-token-here")
Webserver
from quart import Quart, request
from discord.ext.dashboard import Server
app = Quart(__name__)
app_dashboard = Server(
app,
"secret_key",
webhook_url="https://your-private-discord-webhook.com"
)
@app.route("/")
async def index():
guild_count = await app_dashboard.request("guild_count")
member_count = await app_dashboard.request("member_count", guild_id=776230580941619251)
return f"Guild count: {guild_count}, Server member count: {member_count}"
@app.route("/dashboard", methods=["POST"])
async def dashboard():
# Don't worry about authorization, the bot will handle it
await app_dashboard.process_request(request)
if __name__ == "__main__":
app.run()
Please note that cogs are not currently supported. For support join CRYO OFFICIAL
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for discord_ext_dashboard-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 909dba0417a14b1fc48b1703fb1479b259dee7d97e41332f8b21ab30ed17d39e |
|
MD5 | 3f42fefd7a4445f96b4e05e02d059837 |
|
BLAKE2b-256 | e9c616096d680e2d4cf976fa5d36ea93b1dc90a76bf79611bc09b0e15e0847c5 |