This repository has been archived by the owner on May 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Self hosting
xVaql edited this page May 5, 2019
·
32 revisions
This section will explain you how to host the bot yourself.
- Disclaimer
- Downloading the bot and dependencies
- Downloading dependencies
- Creating keys.json
- Setting up your database
- Starting/Inviting the bot
- If not already installed, install Git on your computer
- Open your (git) command line, and enter the directory you would like to install the bot in (most commonly using
cd (folder name)
) - Run the command
git clone https://github.com/xVaql/TimePlayed.git
- If not already installed, install Node.JS on your computer
- Open the command line and enter the directory the bot is installed in (dir should be named TimePlayed) and run the following command:
npm install discord.js mysql fast-levenshtein
- Open your file explorer and enter the directory the bot is installed in
- Create a file named keys.json
- Edit the file using your favorite text editor
- Copy and paste the following text into your file:
{ "beta": false, "selfHost": true, "botToken": "(bot-token)", "mysqlhost": "localhost", "mysqlpasswd": "(database-password)", "mysqlusername": "root" }
- Go to Discord Developers, log in to your Discord account and create a new app
- In the app, go to the
bot
page and create a bot user for your application - Uncheck the
Public Bot
option (self hosting is meant for private use only, you may not host the bot publicly) - At the bot page, click on
Click to Reveal Token
and copy the token - In keys.json, replace
(bot-token)
with your bot's token
- If not already installed, install MySQL on your computer (if on Linux, you can run
sudo apt-get install mysql-server
to install MySQL) - Follow the setup process, make sure to choose a strong password, most of the default settings will be fine
- Make sure the database is running, if the command in step 4 doesn't work run
sudo service mysqld start
orsudo /etc/init.d/mysql start
. - Open the MySQL command line using
mysql -u root -p
, and enter the root password of your database you just set. - Run the following command:
CREATE DATABASE timeplayed;
Make sure to add the semicolon at the end of the command, otherwise the command won't run - Close the MySQL command line (by pressing
CTRL + C
or by runningexit
), enter theTimePlayed
directory, and run the following command:mysqldump -u root -p timeplayed < structure.sql
and enter your root password you have set while setting up MySQL - Go back to editing your keys.json and replace
(database-password)
with the root password of your MySQL database
- Go to the command line and enter the bot's directory
- Run the following command to start the bot:
node bot.js
. This is your startup script, whenever you restart your computer you will have to run this command again to start the bot
Now we're going to invite the bot
- Go back to Discord Developers, click on your app and copy your bot's client ID
- Replace
(CLIENT_ID)
with the ID you just copied in the following link:https://discordapp.com/oauth2/authorize?client_id=(CLIENT_ID)&scope=bot&permissions=268708928
- Copy and paste the link into your browser and invite your bot
That should be it! If everything went right, you should now be able to run TimePlayed commands in your server, and enjoy premium features. If you experienced any trouble during this tuturial, please let me know in my support server and I will help you whenever I can.