A guide to self-hosting CRBT
CRBT isn't fully ready to be self-hosted, with a few config variables missing and the CRBT branding being all over the place. Note that this guide isn't fully complete yet, but should be enough given some basic computer knowledge.
Want to run your own instance of CRBT, under a different branding, with your own commands, or for another reason? This guide is for you!
What is CRBT?
CRBT is the Discord app you need for server management, moderation, adding interactivity and fun to your server! You can learn more about it on CRBT's website.
Create your Discord bot
Detailed steps on how to create your Discord bot can be found in a dedicated article.
- Go to your Discord Developer Portal.
- Click "New Application" on the top right hand corner.
- Name it something, accept the Developer Policies and click "Create".
- Navigate to the "Bot" tab and click "Add Bot".
- Confirm with "Yes, do it!".
- Copy your bot's token and store it somewhere safe like a password manager.
Install Node.js
CRBT is written in the web language JavaScript, but it isn't meant to be run on a web browser. Node.js is a desktop JavaScript runtime environment that lets us develop and build the bot.
To install it, head over to the Node.js download page and choose your OS.
Always prefer the latest LTS version of Node.js, unless you know what you're doing!
Clone CRBT
Download the source code from CRBT's GitHub page by clicking on "Code" then "Download ZIP":
Extract the ZIP file in your file manager, then go inside of the newly created folder. Your folder should look like this:
Set up a database
CRBT uses [Prisma](https://www.prisma.io/client to connect with a remote database, meaning you can set it up pretty much any SQL or MongoDB database.
It is a necessary component that you will need to set up for your bot to work properly.
If you don't know where to start, view how to quickly set up a Supabase instance and configure it with CRBT.
Add environment variables
- Create a file named
.env
and open it with a text editor program, such as Notepad. - Paste in this environment variables example and edit it according to the comments (lines starting with #):
# Paste the bot token you copied earlier in place of YOUR_BOT_TOKEN
DISCORD_TOKEN = YOUR_BOT_TOKEN
# Paste the URL to your database in place of YOUR_DATABASE_URL.
# For example, a PostgreSQL URL should look like `postgres://postgres:[PASSWORD]@[URL]:[PORT]/postgres`
DATABASE_URL = YOUR_DATABASE_URL
- Save the file and breathe for 5 seconds. You went through a lot.
Run your bot
- Open the Terminal:
- Windows: From your CRBT folder, right click an empty spot and select "Open in Terminal".
- Other: Open your terminal app, and type
cd
followed by the path to your CRBT folder.
- Make sure that Node.js is installed by typing
node -v
. Check if it prints out the version you installed earlier.
If this command fails, you may need to reinstall Node.js with these instructions.
- Run the
npm install
command to install all of the dependencies. - Finally, run
npm run dev
. If everything is set up properly, the terminal should print "Logged in as {your bot name}" as the last line. - You're all set!
Add your bot to your server
- Go back to your application's Discord Developer Portal page
- Navigate to the "OAuth2" tab, and head to "URL Generator"
- Check the "bot" and "applications.commands" scopes.
- Click "Copy" and navigate to the copied URL.
- Choose a server to add your bot to, then click "Authorize".
- You are done! You can now type
/help
in any channel and get the same embed as CRBT's!