Skip to content

leafstudiosDot/manubot-discord

Repository files navigation

Manubot for Discord

An open-source Discord bot

This project now includes:

  • Discord Gateway bot runtime (Python)
  • Flask API server (Python)
  • SQLite storage (manubot.db)
  • React + Vite frontend dashboard (src/frontend/)

Source file structure

  • src/main.py: startup/orchestration (loads env, starts Flask thread, runs Discord loop)
  • src/discord.py: Discord Gateway connection, heartbeat, reconnect loop
  • src/webback.py: Flask app factory and API/static routes
  • src/database.py: SQLite schema setup and event read/write helpers
  • src/frontend/: React + Vite dashboard app

Setup

1. Install backend dependencies

pip install -r requirements.txt

2. Development mode

Run backend (Discord bot + Flask API):

python src/main.py

In another terminal run frontend dev server:

cd src/frontend
npm install
npm run dev

Open: http://localhost:5173

3. Production build mode

Build frontend once:

cd src/frontend
npm install
npm run build

Then run backend:

python src/main.py

Flask will serve the built React app from src/frontend/dist

  • http://localhost:6540/ (dashboard)

Docker (single image)

Build a production image (frontend is built inside Docker):

docker build -t manubot:latest .

Run the image with your .env:

docker run --rm -p 6540:6540 --env-file .env manubot:latest

Open: http://localhost:6540

Docker Compose

Compose uses:

  • .env for secrets/config (TOKEN, APP_ID, optional API_PORT)
  • ./data bind mount for persistent SQLite file at /data/manubot.db

Start:

docker compose up --build -d

Logs:

docker compose logs -f

Stop:

docker compose down

Environment variables

Use your .env file:

TOKEN=your_discord_bot_token
APP_ID=your_discord_application_id
API_PORT=6540
DB_PATH=src/manubot.db
SUPERADMIN_USERNAME=superadmin
SUPERADMIN_PASSWORD=change_me_now
# Optional: bcrypt hash version of superadmin password.
# If set, this takes priority over SUPERADMIN_PASSWORD.
# SUPERADMIN_PASSWORD_HASH=$2b$12$...

DB_PATH is optional for local non-Docker runs.

TOKEN and SUPERADMIN_USERNAME are required to run the server.

For superadmin login itself, set either SUPERADMIN_PASSWORD or SUPERADMIN_PASSWORD_HASH.

.env in Docker

  • Do not copy .env into the image.
  • Keep .env on host and pass it at runtime:
    • docker run --env-file .env ...
    • or env_file: .env in Compose (already configured in docker-compose.yml)
  • If you use Compose and also set values in environment:, those explicit environment values win over env_file values for same keys.

Version bump automation

Frontend UI version is now generated from src/frontend/package.json during Vite build, so there are no hardcoded v0.0.x strings to update in React files.

From src/frontend/:

# Increment version locally (no git tag created by npm)
npm run version:patch
npm run version:minor
npm run version:major

Or sync directly from a git tag:

# Use latest git tag (example: v0.0.3)
npm run version:sync-tag

# Or pass explicit tag
npm run version:sync-tag -- v0.0.3

About

A manageable Discord bot

Topics

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Sponsor this project

  •  
  •  

Packages

 
 
 

Contributors