Created
October 24, 2022 09:04
-
-
Save Hunter87ff/7e249f01482740516d8ceaeebfd4f04b to your computer and use it in GitHub Desktop.
discord bot dashboard in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pip install quart | |
#pip install Quart-Discord | |
#pip install discord-ext-ipc | |
from quart import Quart, render_template, url_for, redirect | |
import quart_discord | |
from quart_discord import DiscordOAuth2Session , requires_authorization, Unauthorized | |
from discord.ext import ipc | |
app = Quart(__name__) | |
app.secret_key = b"hunter#6967" | |
app.config["DISCORD_CLIENT_ID"] = CLIENT_ID #https://discord.com/developers/applications/ | |
app.config["DISCORD_CLIENT_SECRET"] = "CLIENT_SECRET" #https://discord.com/developers/applications/ | |
app.config["DISCORD_REDIRECT_URI"] = "htttp://127.0.0.1:5000/callback" #callback Url of website | |
app.config["DISCORD_BOT_TOKEN"] = "TOKEN" | |
dc = DiscordOAuth2Session(app) | |
@app.route("/") | |
async def index(): | |
return await render_template("index.html") | |
@app.route("/login/") | |
async def login(): | |
return await dc.create_session() | |
@app.route("/callback/") | |
async def callback(): | |
try: | |
await dc.callback() | |
except: | |
return redirect(url_for("login")) | |
return redirect(url_for("dashboard")) | |
@app.route("/dashboard/") | |
async def dashboard(): | |
user = await dc.fetch_user() | |
guilds = await user.fetch_guilds() | |
return await render_template("dashboard.html", user=user, guilds=guilds) | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment