Sign inSign up

en3sis/hans

By en3sis

โ€ขUpdated 4 months ago

An open-source Discord bot built with Discord.JS & TypeScript

Image
0

1.9K

en3sis/hans repository overview

Docker Pulls Docker Image Version (tag latest semver) Discord

โ ๐Ÿค– Hans - Discord Bot

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โ , and lots of โค๏ธ

โ Invite to server

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 ๐Ÿ”—โ .

โ Developing Hans

๐Ÿชฌ NOTE: Please consider opening an issue and PR for bugs, suggestions, or new features.


โ ๐Ÿ”… Prepare environment
yarn install
cp .env.template .env
# fill in DISCORD_TOKEN, DISCORD_CLIENT_ID, CRYPTO_KEY, CRYPTO_IV, BOT_GUILD_ID

To create your Discord application, visit the Developer Portalโ .

Docker is required for local development โ€” the dev script spins up a local Postgres 17 container automatically.

โ ๐Ÿ’พ Database

Hans uses Postgres 17 with Drizzle ORMโ . Schema is defined in TypeScript at src/db/schema.tsโ  and migrations are auto-generated into drizzle/.

yarn db:up         # start the dev Postgres + apply migrations
yarn db:psql       # psql into the dev DB
yarn db:studio     # open Drizzle Studio at https://local.drizzle.studio
yarn db:down       # stop the dev DB (data preserved)
yarn db:reset      # wipe and recreate from scratch

When you change the schema:

# 1. Edit src/db/schema.ts
# 2. Generate a migration
yarn db:generate
# 3. Apply it locally
yarn db:migrate
# 4. Commit src/db/schema.ts and the new drizzle/ file

Production migrations are applied separately from your laptop over Tailscale โ€” see infrastructure/README.mdโ .

โ ๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป Development

โ yarn dev

Starts the dev Postgres container (if not running), applies migrations, then launches the bot with nodemon for live-reload. Invite link prints to the console on first boot.

โ Slash commands

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 configs table whose bot_guild_id matches your guild ID. The bot creates this on first connect; otherwise insert one with yarn 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: yarn slash:dev for dev, yarn slash for production.


โ ๐Ÿงช Tests

yarn test          # runs Jest against ./tests

Test coverage is light โ€” contributions welcome, especially around command controllers.


โ ๐Ÿ— Production

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โ .

โ Run the bot image standalone

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=... yarn db:migrate).

Tag summary

Content type

Image

Digest

sha256:5586f9e9dโ€ฆ

Size

93.5 MB

Last updated

over 1 year ago

docker pull en3sis/hans