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, 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.
Before running any command, run npm install && cp .env.template .env
, and fill in all the env variables needed. To create your application, visit Discord's Developer Portal
๐ชฌ IMPORTANT: A Supabase instance is needed for the bot to work. A free cluster should be more than enough (even for small bots & communities) for development.
Supabase is used for storing the bot's configs, guilds, and users.
You can work with supabase local
, follow the instructions here ๐.
Once you run supabase start
the local Supabase will be populated with the latest schema (have a look at the supabase/seed.template.sql
file for more configuration)
More information related to working with Supabase local development can be found ๐น here ๐
Once the Prepare environment
section is done, you can follow along with the development.
It will start a development server with ts-node
and nodemon
for live-reload. A bot Invite link will be displayed in the console.
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 the entry in Supabase
configs -> bot_guild_id
is your guild_id.
All commands under the main folder are available globally (it will take a second to have them available) while the ones under bots-playground/
are guild-specific and are instantly deployed, use this folder for debugging & development purposes.
To deploy the commands: npm run slashDev
or npm run slash
in production.
For testing, we use Mocha with TS.
All the tests are under the /tests
directory. Right now they're none or a few, we should add more test coverage for command controllers.
Will run all the tests.
We have multiple environments for deploying your bot.
You can either use the pre-built Docker image from DockerHub at en3sis/hans:latest
or build your own locally using the command docker build -t en3sis/hans .
To run the container, use the command docker run --env-file .env --name hans -d --restart=always en3sis/hans:latest
while making sure that the .env
file is in the same directory as the command and contains all the necessary environment variables for the bot to function properly.
You can also run it with docker-compose
using the command docker-compose up -d --build bot
.
Note: for M1 Macs, you'll need to use
docker-compose build --build-arg M1=true
before running thedocker-compose up -d
.
You can also run the bot locally using the following commands:
๐ชฌ IMPORTANT: Follow the
Prepare environment
section.
To generate the application's build.
It will run the bot with the production environment.
๐ข NOTE: This is a WIP, it's not fully tested yet, things are missing. Please feel free to contribute.
It's also possible to deploy the bot to a Kubernetes cluster, the necessary files are in the k8s
folder.
Steps:
- You'll need your K8S cluster, ofc ;P
- Create the namespace
kubectl apply -f k8s/namespace.yaml
- Run
cp k8s/secrets.template.yaml k8s/secrets.yaml
, fill it up and apply the secretskubectl apply -f k8s/secrets.yaml
- Deploy the workload
kubectl apply -f k8s/deployment.yaml