Skip to main content

Веб-перехватчик и расширение discord.py на основе запросов для создания панели управления ботом.

Project description

Установка

# ЕСЛИ УСТНОВЛЕН
pip install --upgrade discord-py-dashboard

# ЕСЛИ НЕ УСТАНОВЛЕН
python3 -m pip install --upgrade discord-py-dashboard

Применение

Предпосылки

Прежде чем приступить к работе, вам понадобится несколько вещей:

  • Вебхук в секретном канале (если у кого-то есть доступ, он сможет все получить лягушку а это плохо).
  • Правильно размещенный бот discord.py

И так поехали!(жабы топ)

Примеры

Бот

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")

Веб-сервер

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()

Обратите внимание, что Cogs в настоящее время не поддерживаются.

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-py-dashboard-0.3.1.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file discord-py-dashboard-0.3.1.tar.gz.

File metadata

  • Download URL: discord-py-dashboard-0.3.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.4

File hashes

Hashes for discord-py-dashboard-0.3.1.tar.gz
Algorithm Hash digest
SHA256 40a67f275e328c7bad5fd83712d45f515e500bbfb088968ec79e27b7d3b12ee3
MD5 994638d6fc02037cb11e413150cff415
BLAKE2b-256 d89d25d94ac876b6c413a48afc208782ba7332ae614cf82aa654f560dcf686f9

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