Docker installation¶
Database setup¶
The database holds all dynamic bot data (e.g. the user content). There are multiple options, but we’ll look into two of them: PostgreSQL and SQLite.
PostgreSQL is a program that runs on a server and the bot connects to it. It should be used for production, as it is fast and reliable. It can be set up by running:
apt install postgresql postgresql-contrib libpq-dev
su - postgres
createuser --pwprompt <username> # set strong password
psql -c "CREATE DATABASE <database>;"
exit
The user, its password and database will be your connection string:
postgresql://<username>:<password>@localhost:5432/<database>
SQLite requires no installation and no setup and saves its data into a file. It is much slower and it shouldn’t be used in production (really small servers shouldn’t be a big problem, though). The connection string is just a pointer to the file:
sqlite:///<filename>.db
Create a file called .env in the root directory of your cloned repo and copy the content of the default.env file into it. The .env file will hold sensitive bot information, so don’t let anyone see its content, ever. Open it and paste the connection string into the DB_STRING variable.
See Configuration chapter to learn about database backups.
Guilded bot token¶
The token is form of authentication your bot uses to communicate with Guilded servers.
Go to Guilded Developers page, click [New Application] and fill the form.
Then go to the Bot tab and convert your application to bot. While you’re there, enable both Privileged Gateway Intents (Presence, Server Members), as the bot requires them for some of its functions.
On the top of the page, there is a Token section and a [Copy] button. Open your .env file and put the token in.
You can invite the bot to your server by going to the OAuth2 page, selecting bot scope and Administrator permission to generate URL. Copy it, paste into new tab hit enter. You can only invite the bot to servers where you have Administrator privileges.
Docker¶
Docker containers (bot and database) allow running the bot without touching the hosting environment. On the other hand, it is another management layer (in means of increased CPU/RAM usage on server).
The first step is installing the docker:
sudo apt install docker docker-compose
It will probably be neccesary to add the user to the Docker group (this will take effect on the next session):
sudo usermod -aG docker <username>
For the next command you will probably need to log out and back in to load the group change.
Change current directory to the folder where your cloned repository is and build the container:
docker build .
Then you can run the bot with:
docker-compose down && docker-compose up --build
To run the bot in the background, add --detach parameter:
docker-compose down && docker-compose up --build --detach