Selfhosting
This page explains what to do, should you decide to selfhost the bot.
Prerequisites¶
This page expects you to have knowledge of Java on at least a fundamental level, to execute the necessary java command.
It also expects you to be familiar with Maven to compile the jar, and to have the necessary Java version (Java 21 or newer) installed to compile the jar.
Finally, by selfhosting the bot do you agree to the following Terms:
- You will properly credit the original Creator Andre_601 (Alternatively Andre601) in the bot and follow the requirements of the [MIT License].
- You will not ask for any support with the Bot on our Discord Server. By selfhosting are you responsible for the bot yourself, including any bugs and issues that may occur.
Requirements¶
The bot requires Java 21 or newer to be installed, in order to run. You also need an internet connection to reach the Discord API, meaning it cannot be blocked or the bot won't function.
How much RAM the bot needs depends heavily on how many members and servers it serves. Less than 1GB is sufficient for a private instance serving only a handful of servers.
Finally is a properly setup [RethinkDB] instance required with a Table already setup. The name of the table is what needs to be used later in the config.json file of the bot.
Building the Jar¶
The Project uses Maven to compile a usable jar file. But before you can do that should you first change some parts of the code.
Code modifications¶
Certain parts of your code may require modifications, depending on if your bot would run in Beta mode or not.
Should you enable beta mode will certain parts of the code not be executed. More specifically, the following features will not be activated when running with Beta mode enabled:
- Status API to return JSON on
/shardsendpoint (Used from the main bot for the status page). - Posting of Guild and Shard stats to Bot lists.
Should you want to use one or both of these features are you instead required to modify parts of the code to do so:
In the main PurrBot.java file, scroll to the bottom of the start method and comment out or remove the enableStatusAPI() call.
You can also remove the corresponding method in the class, if desired.
In the main PurrBot.java file, scroll to the enableScheduler() method and comment out or remove anything inside the scheduleAtFixedRate call that is after the if(isMockup() || getFileManager().getBool("config", "beta")) check.
If you want to post to Bot lists, open the BotListManager.java file and modify the List.of call inside the constructor.
Each entry is a BotList instance containing the Path relative to tokens in the config.json for the Bot List API Token, the Bot List's name/domain (used in status responses), the API URL, where {id} is used for the Bot's ID, the name for the guild count filed in the JSON body and the name for the shards count field in the JSON body (Can be null if the site doesn't support it).
Finally, the Constants.java file needs to be modified. It contains constant values used across various parts of the bot:
PURR_IDfor the ID of the bot account used.SNUGGLE_IDfor the ID of the beta version bot account used (Set it to -1 or 0 if there isn't one).DEV_NAMEfor the name of the Developer of the bot (Used in/botinfo).*_LINKfor commonly used links like discord invite, wiki link, donation pages, etc.- Bot List Links to the bot's bot list entries.
Build the jar¶
We use mvn clean package as command to build the jar file. You will find it in the target folder inside the project. The Purr.jar should be the one to use.
Running the Bot¶
After you made sure that the necessary Java and RethinkDB versions are installed where you want to run the bot, execute the java -jar command.
The bot will fail the first time to start. This is expected, as the config.json file doesn't exist yet. It should've been created now after executing the command.
The default config may look something similar to this:
{
"bot_token": "TOKEN",
"support_server": -1,
"owner": -1,
"status": "https://purrbot.site | {guilds} Server",
"beta": false,
"debug": false,
"webhooks": {
"guild": "guild-webhook-url",
"log": "log-webhook-url"
},
"tokens": {
"fluxpoint_dev": "fluxpoint-dev-token",
"discord-bots_gg": "discord-bots-gg-token",
"discordextremelist_xyz": "discordextremelist-xyz-token",
"discordservices_net": "discordservices-net-token"
},
"database": {
"ip": "127.0.0.1",
"name": "DatabaseName",
"guild_table": "GuildTableName"
}
}
The most important values to modify are bot_token, support_server, owner, webhooks settings and database settings.
The first option is for the Discord Bot Token. DO NOT SHARE IT PUBLICLY!
Support server and owner are IDs of your main server and your account respectively. They are required by the Command Library used.
Webhooks contains URLs for Guild and Bot-related events (Guild joins/leaves, bot disconnects/reconnects). The URLs should be valid Discord webhook URLs.
Database contains settings for the RethinkDB database. Should you run it on the same server as the bot can the IP be left unchanged. name and guild table need to be updated to match the database and table name respecively that you set in RethinkDB.
After you've updated the file, save it and run the bot again. It should now load properly.
Note that the tokens section is for additional tokens used for bot lists or the fluxpoint API (Used for the welcome Image).
Should you want to post to bot lists, are you required to modify this section accordingly.
Additional files¶
For the best experience, make sure to create a folder named img in the location of the jar file and add a PNG file named heart to it.
This file is used by the bot for the /ship command and omitting it will result in the bot not creating an image for the command being used.