Hans is built with a modular architecture that makes it easy to add and remove functionality on the fly, empowering you to create a bot tailored to your community's needs.
Built with Discord.JS, TypeScript, Postgres 17, Drizzle ORM, running on Bun, and lots of ❤️
Bring Hans to your Discord server and start using his available features immediately here 🔗. It uses the latest hans:nightly image with the latest features.
The list of commands & plugins can be found here 🔗.
🪬 NOTE: Please consider opening an issue and PR for bugs, suggestions, or new features.
Requires Bun ≥ 1.3 (curl -fsSL https://bun.sh/install | bash) and Docker.
bun install
cp .env.template .env
# fill in DISCORD_TOKEN, DISCORD_CLIENT_ID, CRYPTO_KEY, CRYPTO_IV, BOT_GUILD_IDTo create your Discord application, visit the Developer Portal.
Hans uses Postgres 17 with Drizzle ORM.
Schema is defined in TypeScript at src/db/schema.ts
and migrations are auto-generated into drizzle/.
bun run db:up # start the dev Postgres + apply migrations
bun run db:psql # psql into the dev DB
bun run db:studio # open Drizzle Studio at https://local.drizzle.studio
bun run db:down # stop the dev DB (data preserved)
bun run db:reset # wipe and recreate from scratchWhen you change the schema:
# 1. Edit src/db/schema.ts
# 2. Generate a migration
bun run db:generate
# 3. Apply it locally
bun run db:migrate
# 4. Commit src/db/schema.ts and the new drizzle/ fileProduction migrations are applied separately from your laptop over Tailscale — see infrastructure/README.md.
Starts the dev Postgres container (if not running), applies migrations,
then launches the bot with Bun's built-in --watch for live-reload.
Invite link prints to the console on first boot.
All commands (under src/commands) are built with the Slash Command interaction.
🪬 IMPORTANT: before developing commands, make sure you invite the bot to your server and that there is a row in the
configstable whosebot_guild_idmatches your guild ID. The bot creates this on first connect; otherwise insert one withbun run db:psql.
Commands under the main folder are registered globally (takes a moment
to propagate). Commands under bots-playground/ are guild-specific and
deploy instantly — use that folder for debugging.
To redeploy commands: bun run slash:dev for dev, bun run slash for production.
bun test # runs Bun's native test runner against ./testsTest coverage is light — contributions welcome, especially around command controllers.
Lint and typecheck:
bun run lint # eslint --fix
bun run typecheck # tsc --noEmitCI runs all three on every PR (see .github/workflows/ci.yml).
Production runs on a single Hetzner VPS as two Docker containers
(db + bot) managed by docker compose. Deploys are manual: SSH to
the box and run ./infrastructure/ops/deploy.sh. Schema migrations
are applied from your laptop over Tailscale.
The full production playbook — host setup, deploy flow, Tailscale configuration, backups, rollback, and the one-time data-migration procedure — lives in infrastructure/README.md.
If you just want to run the bot against your own Postgres:
docker run --env-file .env --name hans -d --restart=always \
en3sis/hans:nightly.env must include a DATABASE_URL reachable from the container. You
are responsible for applying schema migrations against that DB before
the bot connects (DATABASE_URL=... bun run db:migrate).