Skip to main content

A webhook and request based discord.py extension for making a bot dashboard.

Project description

Discord Server License Version Downloads Supported Versions

discord-ext-dashboard

A webhook and request based discord.py extension for making a bot dashboard.

Installation

pip install --upgrade discord-ext-dashboard

# If that doesn't work
python3 -m 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",
	sleep_time=1
)

@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.
You will also need to use Quart as your webserver. Switching from another library isn't hard, so ask me and I'll gladly help you out.

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 Distribution

discord-ext-dashboard-0.2.7.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file discord-ext-dashboard-0.2.7.tar.gz.

File metadata

  • Download URL: discord-ext-dashboard-0.2.7.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.8.0 tqdm/4.60.0 CPython/3.8.9

File hashes

Hashes for discord-ext-dashboard-0.2.7.tar.gz
Algorithm Hash digest
SHA256 b4151f800c7728758594764717bd82dbe130505f88366f7fa918605cccc09183
MD5 8b1faf4dc01c16215221c6148b29bba3
BLAKE2b-256 8c8d7a5843d8aab639d06d304014aef0cf5cccf03ab47bc86a82f183457db297

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page