Browse documentation

Host a Discord bot and its HTTPS dashboard

Run a Discord gateway bot and a web app in one deployment. Register your platform HTTPS address as a Discord OAuth2 redirect and test sign-in.

Choose a bot with dashboard profile

In Hosting di bot Discord, choose Node.js bot with dashboard o Python bot with dashboard when available. These profiles reserve an HTTP port and run the bot and site in one deployment. To follow this guide, choose Parti da un esempio and then Add example files in Overview.

To upload the sample yourself, download the Node.js archive o il Python archive. Place its files at the root of the deployment. The samples use index.js e main.py respectively, and listen on 0.0.0.0 e SERVER_PORT.

Register the Discord OAuth2 redirect

  1. Open Settings → HTTP domains and copy the platform HTTPS address. Append /oauth/callback to the HTTPS origin. For example, https://my-bot.bothosting-sites.pages.dev/oauth/callback.
  2. Open your application in the Discord Developer Portal. Under OAuth2, add the full URL under Redirects and save it. Use the same address in DISCORD_REDIRECT_URI.
  3. In Bothosting’s Variables, save the bot token in BOT_TOKEN, the application ID in DISCORD_CLIENT_ID, and the OAuth2 client secret in DISCORD_CLIENT_SECRET. Imposta DISCORD_DASHBOARD_USER_ID to your numeric Discord user ID. Enable Developer Mode in Discord to copy it from your profile.

Install this Discord application in your test server with the bot e applications.commands scopes. The starter requests identify e guilds at sign-in. Only the configured Discord account can sign in. To edit the reply for a server where the bot is installed, that account must own the server or have Manage Server or Administrator permission. Keep the bot token and OAuth2 secret in Variabili.

Test the gateway and browser sign-in

  1. Start the deployment and wait for the Discord gateway connection message in Console.
  2. Open the platform URL with /healthz appended. Expect HTTP 200 once the bot connects.
  3. Select Open dashboard on the deployment card or Overview to open the platform address. If you configured a custom address in Discord, open that address directly. Choose Sign in with Discord, select a server under Server settings, edit and save the reply, and send /dashboard-check in that server. Restart and repeat the command to verify the setting persisted.

Open the dashboard on the hostname in DISCORD_REDIRECT_URI so the browser can return its sign-in cookie on the callback. If Discord rejects the redirect, compare the exact registered URL with the saved variable. If the dashboard refuses access, compare the signed-in account’s ID with DISCORD_DASHBOARD_USER_ID. To move to a verified custom hostname, register its full callback in Discord, update the saved URI, and restart before signing in there.

Bring an existing bot and dashboard

Start your gateway client and HTTP server together from the same project. Bind HTTP to 0.0.0.0 e SERVER_PORT. Use MAIN_FILE o RUN_COMMAND to launch your project. If your existing Discord worker has no HTTP allocation, create a dashboard deployment and move the code there. Stop the old bot before starting the new deployment with the same token.

The edge preserves the sample’s two host-only session and OAuth2 state cookies. The starter checks Discord permissions on each settings request and writes one file per server under .discord-dashboard. Include that directory in backups when moving the bot. Restarting ends dashboard sessions, and saved replies stay on disk. The example installs /dashboard-check as a server-only command. Discord’s guild permission data.