Selfhosting
If you want to run this bot on your own computer you're probably looking at selfhosting.
Intents
One thing to keep in mind is that this bot relies heavily on the presence intent in Discord's bot config. Without it the bot will not function correctly. Read more about intents here.
Environment Variables
In the following examples environment variables are defined.
If you're running Dynamica without docker they should be placed in a .env
file in the Dynamica folder using the following structure:
CLIENT_ID=<client_id>
TOKEN=<token>
GUILD_ID=<guild_id> # Optional
DATABASE_URL=<database_url>
MQTT_URL=<mqtt_url> # Optional
MQTT_USER=<mqtt_user> # Optional
MQTT_PASS=<mqtt_pass> # Optional
With the database url by default the location is file:/app/config/db.sqlite
. If you want to change this make sure you have a volume corresponding to the file path. Otherwise your data won't be saved across restarts.
warning
Make sure to replace <client_id>
,<token>
and <guild_id>
with the correct values.
Without Docker
- Clone the repository here.
- Run
yarn install
to install the dependancies. - Run
yarn build
to build to JavaScript. - Run
yarn prisma migrate deploy
to create the database. - Run
yarn deploy
to deploy the commands to the server or guild. - Run
yarn start
to start the bot.
warning
The configuration files are stored by default in the config
folder. Don't delete this if you want the bot to work properly.
Updating
When you want to update:
- If the bot is running simply stop it using
Control
+c
- Run
git pull
to get the latest changes. - Repeat steps 2-4 of the installation.
With Docker
Prerequisites
As part of the install you're going to need Docker or Docker Compose if you want to use a compose file.
CLI
docker run -d \
--name=dynamica \
-e CLIENT_ID=<client_id> \
-e TOKEN=<token> \
-e GUILD_ID=<guild_id> \ #optional
-e MQTT_URL=<mqtt_url> \ #optional
-e MQTT_USER=<mqtt_user> \ #optional
-e MQTT_PASS=<mqtt_pass> \ #optional
-v </path/to/config>:/app/config \
--restart unless-stopped \
ghcr.io/dynamicabot/dynamica
Compose
---
version: "2.1"
services:
discordbot:
image: ghcr.io/dynamicabot/dynamica
container_name: dynamica
restart: unless-stopped
volumes:
- </path/to/config>:/app/config
environment:
- CLIENT_ID=<client_id>
- TOKEN=<token>
- GUILD_ID=<guild_id> # optional
- MQTT_URL=<mqtt_url> # optional
- MQTT_USER=<mqtt_user> # optional
- MQTT_PASS=<mqtt_pass> # optional
Pterodactyl Egg
Another option for self-hosting is a Pterodactyl Egg.
For that you can use this file.
warning
Make sure that the directory that you have your database stored in is persistent across restarts.