Skip to content
All courses

Advanced Discord bot with a web dashboard

Database, cogs, Log in with Discord, and a site that changes your bot's settings live.

$5Spicy 6 levels about 57 min badge: Dashboard Dev

The step after your first bot. We build a welcome feature whose channel and message are set from a web page, the same way big bots do it: the bot and the website share one database, the website logs people in with Discord, and only people who manage a server can change it. Python all the way (discord.py and Flask). Finish the free bot course first, or know what a slash command is.

By Dispresso

Playing as a guest. Level 1 is yours to try. Sign in to save XP, keep a streak and earn the badge.

Sign in to save

Level 1 of 6

The plan (read this, it saves hours)

About 5 minutes

Here's the trick nobody tells you: the website and the bot don't talk to each other. They both talk to the same database. The site writes a setting, the bot reads it the next time it needs it. No sockets, no magic.

  1. You on the site
  2. Flask dashboard
  3. data.db
  4. The bot
  5. Your server

The project ends up looking like this:

the folder
mybot/
  .env            # tokens and secrets, never in git
  db.py           # every database read and write
  bot.py          # starts the bot, loads cogs
  cogs/
    welcome.py    # the welcome feature
  web.py          # the Flask dashboard
  templates/
    servers.html
    server.html
  data.db         # made for you on first run
bash
python -m pip install -U discord.py python-dotenv flask requests

Two processes, one database. That's the whole architecture. When something breaks later, ask "which side wrote it and which side read it" and you'll find the bug twice as fast.

Boss question

Someone changes the welcome message on the dashboard. How does the bot find out?