Skip to content

Self‐hosting

Reishi edited this page Feb 28, 2024 · 15 revisions

Table of contents: Self-hosting

  1. Dependencies
  2. Step-by-step tutorial
  3. Video tutorial
  4. Common issues
  5. Useful resources

Dependencies

This bot relies on a bunch of stuff to work. Here's a list of all required (and optional) things to install:

Dependency Why? Optional
Lavalink server This is required for the bot to be able to play music from different sources
NodeJS Required to run the typescript code
Postgres database This is only required if you want the bot to store statistics (like sessions count)

Tip

If you don't have a Postgres database or just don't want to use one, you can set the database key inside of config.yml to sqlite to use a local sqlite3 database instead!

Step-by-step tutorial

1. Download Lavalink:

Caution

You must use version 3.x.x of lavalink!

Warning

The Lavalink server must be running in the background while the bot is online!
Due to how poru works if the bot disconnects from Lavalink it WILL crash after a couple of attempts to reconnect.

  • If you don't have it yet install Java JDK 17, then check if Java installed successfully by opening a terminal window and typing in java --version
  • Go to the lavalink repository and download the lavalink .jar file
  • Make sure lavalink works by running it with the java -jar path_to_lavalink.jar command

2. Install Node JS

  • Go to the Node JS download page and install the LTS version (preferably 18.x)
  • To test if node.js is installed correctly open a new terminal window and input the node --version command

3. Get a discord bot token

  • Go to the discord developer portal and create a new application
  • Create a new bot for your application and copy the token
  • Rename the config.example.yml file to config.yml instead
  • Paste the bot token into the config.yml file

4. Clone the project and install dependencies

Tip

Instead of cloning the code using git you can download the ZIP file from the main repo's page

  • Clone the source code with git clone https://github.com/Reishimanfr/The-World-Machine-Bot (or just download the ZIP file)
  • Go into the newly created directory "The-World-Machine-Bot"
  • Run npm install --omit=dev

5. Configure the project

Warning

You must set the playerUpdate option in application.yml to 1s! Explanation available here

  • Copy the example application.yml file from the lavalink's website and place it in the project's root folder (the same one where you can find package.json. Change the password for the lavalink server.
  • Go to the config.yml file and fill it out with the required stuff. To see what's required check this page
  • Go to the src/config.ts file and define a lavalink node inside the poruNodes array.

6. Deploy (/) commands and start the project

Warning

If you change the autocomplete option in config.yml, you must rerun the deploy script!

  • After filling out the config.yml file run the npm run deploy command to register (/) commands globally.
  • Run the npm run start command to start the app after making sure lavalink is running