Discord Bot build with Discord.JS, TypeScript, and lots of ❤️
You can invite the bot here 🔗. It's using the latest hans:nightly
image with the latest features.
The list of commands can be found here 🔗 and, the list of functionalities 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
, fill all the env variables needed. To create your application, visit Discord's Developer Portal
🪬 IMPORTANT: A MongoDB instance is needed for the bot to work. A free Atlas cluster should be more than enough (even for small bots & communities) for development.
An alternative is to spin a MongoDB instance yourself with Docker locally.
Use docker compose up -d
command to start it. docker-compose down
to stop it.
MongoDB Compass is recommended. Your connection string should be mongodb://hans:S3cret@localhost:27017
Will start a development server with ts-node and nodemon for livereload. A bot Invite link will be displayed in the console. Use it to invite the bot to your server.
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 mongodb
hans -> config
has the commandsDevGuild.id set to your server 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.
🪬 IMPORTANT: Since the command process is isolated, make sure to export the mongodb connection string to your current shell, ex:
export MONGODB_CONNECTION="mongodb://hans:S3cret@localhost:27017"
For testing, we use Mocha with TS.
All the tests are under the /tests
directory. Right now they're none or a few, ideally, we should add more test coverage for command controllers.
Will run all the tests.
We have multiple environments for deploying your bot (see Deployment section below). The easiest way would be to clone the repo and do:
🪬 IMPORTANT: Make sure to follow the
Prepare environment
section.
To generate the application's build.
Will run the bot with the production environment.
There's an image in the DockerHub at en3sis/hans
with the latest version or you can build your image.
Build it locally with docker build -t en3sis/hans .
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