panda_games_swat

Make me a website where i can simply manage my discord bot. The website requires a discord login to view any information about the bot. Once loged in the user will see normally no information unless they are permitted to. Make the community owner automaticly have the role owner on the dashboard wich has full control over everything. Make the dashboard have: A bot status tab, tickets tab, moderation tab, applications tab and a role management tab for now. Do not make any extra systems just yet. Make the website dark theme with a clean bit of minecraft theme.

Kodari AI
KodariSep 2 at 11:14 am 2
DiscordBotDashboard
A dark-themed Minecraft-styled web dashboard for managing a Discord bot. Users must log in via Discord OAuth to access any data. The community owner automatically receives the owner role with full control. The dashboard features tabs for bot status, tickets, moderation, applications, and role management, with permission-based visibility for other users.
  1. Create the Flask Discord OAuth2 dashboard with owner detection and permission-gated modules.

  2. Add the dark Minecraft-inspired dashboard UI with status, tickets, moderation, applications, and role-management tabs.

  3. Add secure configuration, role-management API endpoints, and setup documentation.

  1. Built a Flask-based Discord dashboard with Discord OAuth2 login and session security.

  2. Added automatic community-owner access with full owner permissions.

  3. Added role-based dashboard access:

    • Owner: full access

    • Admin: status, tickets, moderation, applications

    • Moderator: status, tickets, moderation

    • Viewer: bot status only

    • Unassigned users: no dashboard information

  4. Added dashboard tabs for bot status, tickets, moderation, applications, and role management.

  5. Added Discord API integration, CSRF protection, SQLite role storage, responsive dark Minecraft-inspired styling, .env configuration, and setup documentation.

Run with:

Shell
cp .env.example .env
pip install -r requirements.txt
python app.py

Then open http://localhost:5000.

panda_games_swat

Can you tell me what i need to change and do to view the website? It also gives me a error that it cant find the discord bot.

Kodari AI
KodariSep 2 at 11:34 am 1
  1. Make the status page show the actual Discord API failure instead of only “Not connected.”

  2. Make .env loading reliable even when the app is launched outside its folder.

  3. Add the exact Discord setup and troubleshooting steps for the bot, server ID, token, OAuth redirect, and member permissions.

The dashboard does not create or run a Discord bot itself. It connects to an existing bot through Discord’s API, so you must create and invite the bot first.

I also updated the dashboard so the status page displays the actual Discord API error, such as HTTP 401 or 404.

1. Create the .env file

Make sure .env is in the same folder as app.py:

Env
DISCORD_CLIENT_ID=your_application_client_id
DISCORD_CLIENT_SECRET=your_application_client_secret
DISCORD_BOT_TOKEN=your_bot_token
DISCORD_GUILD_ID=your_server_id
DISCORD_REDIRECT_URI=http://localhost:5000/callback
SESSION_SECRET=use-a-long-random-secret
PORT=5000
COOKIE_SECURE=false

Use the values from the Discord Developer Portal:

  • DISCORD_CLIENT_ID: Application ID from General Information

  • DISCORD_CLIENT_SECRET: Client Secret from General Information

  • DISCORD_BOT_TOKEN: Token from the Bot page

  • DISCORD_GUILD_ID: Your Discord server ID, not the bot ID

Do not put Bot before the bot token.

2. Configure Discord OAuth

In the Discord Developer Portal:

  1. Open your application.

  2. Go to OAuth2 → General.

  3. Add this exact redirect URL:

Plain Text
http://localhost:5000/callback

The URL in Discord must exactly match:

Env
DISCORD_REDIRECT_URI=http://localhost:5000/callback

3. Configure and invite the bot

In the application’s Bot section:

  1. Create the bot if one does not exist.

  2. Click Reset Token and copy the new token into .env.

  3. Enable Server Members Intent.

  4. Go to OAuth2 → URL Generator.

  5. Select the bot scope.

  6. Give the bot at least:

    • View Channels

    • Send Messages

    • Read Message History

Use the generated URL to invite the bot to the server you want to manage.

The bot must be inside the server specified by DISCORD_GUILD_ID.

4. Find your server ID

In Discord:

  1. Open User Settings → Advanced.

  2. Enable Developer Mode.

  3. Right-click your server.

  4. Click Copy Server ID.

  5. Paste that value into:

Env
DISCORD_GUILD_ID=...

5. Install and start the website

From the project folder, run:

Windows

Shell
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
python app.py

macOS/Linux

Shell
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python app.py

Then open:

Plain Text
http://localhost:5000

Sign in using a Discord account that belongs to the configured server.

If it still says the bot cannot be found

Check the status message on the dashboard:

  • HTTP 401: The bot token is invalid, expired, or copied incorrectly. Reset the token and update .env.

  • HTTP 404: The server ID is wrong, or the bot has not been invited to that server.

  • HTTP 403: The bot lacks access or the required intent is disabled.

  • Members cannot be loaded: Enable Server Members Intent, then restart the website.

Always restart the website after changing .env:

Shell
python app.py

Also make sure the file is named exactly .env, not .env.txt.

panda_games_swat

in the web console i get this error

Kodari AI
KodariSep 2 at 11:40 am 1

The generation was stopped before any content could be produced.

panda_games_swat

In the web console i get this error: Bot failed: No Discord token found. Make sure your bot has a .env file with DISCORD_TOKEN

Kodari AI
KodariSep 2 at 11:41 am 1
  1. Fix token compatibility: accept the console’s DISCORD_TOKEN name while preserving DISCORD_BOT_TOKEN.

  2. Update the example environment file and setup instructions so the required variable is unambiguous.

The website was looking only for DISCORD_BOT_TOKEN, while your hosting console requires DISCORD_TOKEN. I updated it to support both names.

In your .env file, use:

Env
DISCORD_TOKEN=your_actual_discord_bot_token

Do not include:

Env
DISCORD_TOKEN=Bot your_token

Use only the token itself after =.

Then:

  1. Open the Discord Developer Portal.

  2. Select your application.

  3. Go to Bot.

  4. Click Reset Token or Copy Token.

  5. Paste the new token into .env.

  6. Save the file.

  7. Restart or redeploy the website.

Your .env should also contain:

Env
DISCORD_CLIENT_ID=your_application_client_id
DISCORD_CLIENT_SECRET=your_application_client_secret
DISCORD_TOKEN=your_bot_token
DISCORD_GUILD_ID=your_server_id
DISCORD_REDIRECT_URI=http://localhost:5000/callback
SESSION_SECRET=your_long_random_secret
PORT=5000
COOKIE_SECURE=false

The bot token is different from the client ID and server ID. If the error continues, make sure the variable is named exactly DISCORD_TOKEN and that your hosting platform has been restarted after adding it.

panda_games_swat

Now the web console says this: Bot failed: No valid bot file found. Expected: Python: bot.py, main.py, discord_bot.py | Javascript: bot.js, index.js, main.js | Typescript: bot.ts, index.ts, main.ts | Csharp: Program.cs, Bot.cs, Main.cs | Cpp: bot.cpp, main.cpp | Ruby: bot.rb, main.rb, discord_bot.rb | Php: bot.php, index.php, main.php

Kodari AI
KodariSep 2 at 11:43 am 1
  1. Add the expected bot.py entrypoint so the host can start the project.

  2. Run the dashboard web server alongside a minimal Discord bot process.

  3. Add discord.py to the dependencies and document which file to launch.

The console is looking for a Discord bot entry file. I added bot.py, which starts both:

  • The Discord bot

  • The Flask website dashboard

I also added discord.py to requirements.txt.

Use this startup command in your web console:

Shell
python bot.py

Make sure your environment variables include:

Env
DISCORD_TOKEN=your_actual_bot_token
DISCORD_CLIENT_ID=your_application_id
DISCORD_CLIENT_SECRET=your_client_secret
DISCORD_GUILD_ID=your_server_id
DISCORD_REDIRECT_URI=https://your-domain.com/callback
SESSION_SECRET=your_long_random_secret
PORT=5000

Then restart or redeploy the project.

Important:

  • Do not include Bot before the token.

  • The token must be from Discord Developer Portal → Bot.

  • DISCORD_GUILD_ID must be your Discord server ID.

  • The bot must already be invited to that server.

  • Your OAuth redirect URL in Discord must exactly match DISCORD_REDIRECT_URI.

  • The console must install dependencies from requirements.txt.

The expected entry file now exists:

Plain Text
bot.py

For local testing, run:

Shell
pip install -r requirements.txt
python bot.py

Then visit:

Plain Text
http://localhost:5000
panda_games_swat

Great now how can i view the website? The project is ONLY on this website. Can you tell me step by step how i can view the website?

Kodari AI
KodariSep 2 at 11:46 am 1

The project files are not automatically published to the internet. You need to run the web server through the online console, then open the platform’s web preview or generated URL.

Step 1: Open the project console

Open the website where your project files are stored and confirm these files exist:

Plain Text
app.py
bot.py
requirements.txt
templates/
static/

Step 2: Add the environment variables

Open the platform’s Environment Variables, Secrets, or .env section and add:

Env
DISCORD_TOKEN=your_bot_token
DISCORD_CLIENT_ID=your_application_id
DISCORD_CLIENT_SECRET=your_client_secret
DISCORD_GUILD_ID=your_discord_server_id
DISCORD_REDIRECT_URI=https://YOUR_PUBLIC_URL/callback
SESSION_SECRET=make_a_long_random_value
PORT=5000
COOKIE_SECURE=false

For initial testing, if you do not have a public URL yet, use:

Env
DISCORD_REDIRECT_URI=http://localhost:5000/callback

Do not add Bot before the token.

Step 3: Install the dependencies

In the web console terminal, run:

Shell
pip install -r requirements.txt

If the platform automatically installs requirements.txt, you can skip this step.

Step 4: Start the project

Set the platform’s Start Command, Run Command, or Startup Command to:

Shell
python bot.py

Then click Run, Start, or Deploy.

You should see output similar to:

Plain Text
Running on http://0.0.0.0:5000

Keep this process running. Do not close the console or stop the process.

Step 5: Open the website

Look around the console for one of these buttons:

  • Open Web Preview

  • Web Preview

  • Open Port

  • View Website

  • Open App

  • Public URL

  • An icon that looks like a globe or external link

Open port:

Plain Text
5000

The platform should open the dashboard in a new browser tab. You should see the Discord login page.

If the platform gives you a URL such as:

Plain Text
https://your-project.example.com

visit that URL directly.

Step 6: Configure the Discord redirect URL

Once you know the website’s real URL, update your environment variable:

Env
DISCORD_REDIRECT_URI=https://your-project.example.com/callback

Then go to:

Discord Developer Portal → Your Application → OAuth2 → General

Add the exact same URL:

Plain Text
https://your-project.example.com/callback

The URLs must match exactly, including:

  • https

  • the domain

  • /callback

  • any port number

  • no extra trailing slash

Restart the project after changing the variable.

Step 7: Log in

Open the website URL and click the Discord login button.

Log in with a Discord account that belongs to the server configured in:

Env
DISCORD_GUILD_ID=your_server_id

The server owner should automatically receive the owner role and have access to every dashboard tab.

If there is no “Web Preview” or public URL

Some Discord bot hosting websites only run bot processes. They do not host websites or expose HTTP ports. In that case, the console may accept bot.py, but it still cannot display the Flask website.

You need a hosting platform that supports a web service and exposes port 5000. Look for an option named:

Plain Text
Web App
Web Service
HTTP Server
Expose Port
Port Forwarding

If the platform only offers Bot, Worker, or Background Process, it cannot host this dashboard there. You would need to deploy the website portion to a web-service host and keep the Discord bot configured with the same environment variables.

panda_games_swat

I dont have access to the terminal i can only view logs on the website.

Kodari AI
KodariSep 2 at 11:47 am 1

Logs only show what is happening; they are not a webpage preview. The project files are not automatically published just because they exist on the website.

You need to check whether the platform supports web applications, not only Discord bot hosting.

If the platform has a web preview

Look for buttons or settings named:

  • Deploy

  • Run

  • Start

  • Preview

  • Open App

  • Public URL

  • Expose Port

  • Web Service

Configure it with:

Plain Text
Start file: bot.py
Port: 5000

Add the environment variables through the platform’s Settings, Environment, or Secrets page:

Env
DISCORD_TOKEN=your_bot_token
DISCORD_CLIENT_ID=your_application_id
DISCORD_CLIENT_SECRET=your_client_secret
DISCORD_GUILD_ID=your_server_id
DISCORD_REDIRECT_URI=https://your-public-url/callback
SESSION_SECRET=a-long-random-secret
PORT=5000
COOKIE_SECURE=true

After deploying, the platform should provide a URL such as:

Plain Text
https://your-project.example.com

That URL is where you view the website.

Then add this exact callback URL in the Discord Developer Portal:

Plain Text
https://your-project.example.com/callback

Go to:

Discord Developer Portal → Your Application → OAuth2 → Redirects

If you can only view logs

If the website gives you only logs and does not provide a Run, Deploy, Preview, Public URL, or Port option, it is probably a Discord-bot-only host. It can run bot.py, but it cannot display the Flask dashboard.

In that case, no change to the Python files can make the website accessible from that host. You need either:

  1. A hosting plan that supports a web app/HTTP port, or

  2. A separate web hosting service for the dashboard.

The Discord bot can remain on the current platform, while the Flask website runs on a web-service host. The website host must provide a public URL because Discord OAuth requires a callback URL.

Also, the previous bot.py file only gives the host a valid bot entry file—it does not automatically publish the Flask website. Look in the platform’s project settings for its hosting type. If you send the platform’s name or a screenshot of the project page, I can give you the exact buttons and settings to use.

Kodari can make mistakes. Review important code before using.
Files
static
templates
.gitignore
app.py
bot.py
README.md
requirements.txt
Code
9 754
bot.py
import os
import threading

import discord
from dotenv import load_dotenv

from app import app, init_database


load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN") or os.getenv("DISCORD_BOT_TOKEN", "")
PORT = int(os.getenv("PORT", "5000"))

if not TOKEN:
    raise RuntimeError("No Discord token found. Set DISCORD_TOKEN in .env or your host's environment variables.")


def run_dashboard():
    init_database()
    app.run(host="0.0.0.0", port=PORT, debug=False, use_reloader=False)


intents = discord.Intents.none()
client = discord.Client(intents=intents)


@client.event
async def on_ready():
    print(f"Discord bot is online as {client.user}")


if __name__ == "__main__":
    threading.Thread(target=run_dashboard, daemon=True).start()
    client.run(TOKEN)