# Bot-Hosting.net Wiki

Bot-hosting.net provides free hosting designed for Discord bots also capable of running other programs in a large range of languages

Choose a guide now.

{% content-ref url="/pages/zCO6r143mmdP6r6UrbeE" %}
[Hosting your first bot](/guides/hosting-your-first-bot)
{% endcontent-ref %}

{% content-ref url="/pages/FIr1yxbhqeCxFpietgnA" %}
[Cloning a Git repository on your server](/guides/cloning-a-git-repository-on-your-server)
{% endcontent-ref %}

{% content-ref url="/pages/lrbivS56ltzadKvP6RtD" %}
[Connecting to your server's files with SFTP](/guides/connecting-to-your-servers-files-with-sftp)
{% endcontent-ref %}


# Hosting your first bot

This guide will teach you how to host your first bot on bot-hosting.net

**Contents:**

[Coins](#coins) - The coins system explained

[Creating the server ](#creating-the-server)- How to create your server

[Setting up your server ](#setting-up-your-server)- How to upload and run your code

To start with you must login at <https://bot-hosting.net/login> with Discord. Your account will be linked to all your servers.

## Coins

Bot-hosting uses a coin system, servers cost a certain amount of coins every week/month, so you need coins to create your server and keep it running.

There are two ways to get coins, both can be accessed on the earn coins page.

<figure><img src="/files/2IrzwLlPD3q8Ubij2a5F" alt=""><figcaption></figcaption></figure>

The first way to earn coins is using the free coin generator, every user is able to claim 10 coins completely for free. The generator can be found at the top of the earn coins page. You must complete the captcha and then click the button labelled `Click here to claim one free coin!`. You can do this 10 times every day.

<figure><img src="/files/qTTQ05gHp7Ng6bgfqFNh" alt=""><figcaption></figcaption></figure>

Alternatively you can purchase coins with money. This may be required if your bot requires more resources.

## Creating the server

You should select `Create Server` on the navbar down the side. You will see a page where you can enter your server requirements.

You will first be prompted for a name and language. The name is what you want the server to be referred to as, this is for you to help identify it if you have multiple servers. The language is the programming language that your bot was coded in. You must select the correct language so the server is compatible with your bot. **Please note:** We have had multiple users confuse Java with Node.js, JavaScript and Java are completely different languages.

You should click next once you have filled in these details.

<figure><img src="/files/IrEGUa7S1hfri0Asbh6Y" alt=""><figcaption></figcaption></figure>

You will then be asked to select a plan, each plan comes with different server specifications. Depending on the complexity of your bot, intensity of the tasks your bot performs and the amount of servers your bot is in you will need to select a suitable plan. You can always change your plan again later on.

You can view the price of the plans, this is how many coins you will have to pay either every week or every month.

<figure><img src="/files/5ue8Rd4c1JZgWTfmwTIA" alt=""><figcaption></figcaption></figure>

You will then be prompted to select your billing cycle. This is how often you will be charged coins. Your options are either weekly or monthly. For most people weekly is more ideal as it enables more flexibility with servers however others may prefer to see their coins billed once a month.

In the end, whatever you choose isn't that important so choose whichever you'd prefer.

<figure><img src="/files/RvBfGiOPlJKzpOns1RUZ" alt=""><figcaption></figcaption></figure>

Finally you will have to confirm creation. Alternatively you will have the option to subscribe to a paid subscription where coins are not involved.

<figure><img src="/files/Jso7onMi2ZkJgyEytrpj" alt=""><figcaption></figcaption></figure>

Once you confirm creation your server will be created and the installation process will be initiated!

## Setting up your server

Now that you have created a server, you should be able to view it on the `Manage Servers` page. You can click manage server on it.

<figure><img src="/files/HY9yRdRgSwzsgqbzce03" alt=""><figcaption></figcaption></figure>

You can then view your server on the control panel, this is where you will upload files, start/stop your server and configure it.

<figure><img src="/files/n9ANWtAmwGFL3ff0qZv3" alt=""><figcaption></figcaption></figure>

If this is your first time entering the control panel, you will be prompted to login with Discord again

Once logged in you should then be able to see your server on the control panel. You can select it.

<figure><img src="/files/Bar8s7qwV4D2CFiQ2XyB" alt=""><figcaption></figcaption></figure>

You should now see your server like this. As you can see along the top you have a lot of tabs to control different aspects of the server. The first thing you should do is upload your files.

There are two ways to upload your files, either in the files tab or if you are uploading lots of files or want to integrate file uploads in to your deployment system you can use the file upload protocol, SFTP. If you wish to use SFTP you can find your credentials on the settings page in the control panel navbar for your server.

If you wish to upload your files using the files tab and file selector, click files in the navbar along the top of your server and then click upload. You should upload your files in a compressed format such as `.zip` or `.gz` or any other compression format. Then when it's on the server click the 3 dots next to the file and click `Unarchive` to extract it.

{% hint style="warning" %}
If you are using node.js you don't need to upload your `node_modules` folder as the server can automatically install your packages as long as you upload your `package.json` file.
{% endhint %}

<figure><img src="/files/nC1vuhLwbu95eQmIroPE" alt=""><figcaption></figcaption></figure>

Your files will most likely decompress in to a folder, you should move your files out of the folder, doing this is easy. First click open the folder you just extracted the files in to.

<figure><img src="/files/QwVifHje70wPBStElMUr" alt=""><figcaption></figcaption></figure>

Then select all the files, using the check box next to them, you should now see a menu appear on your server, where you can click `Move`.

<figure><img src="/files/XONS0Rx1PBHNLx5Llvof" alt=""><figcaption></figcaption></figure>

This will open a modal where you can enter the path to move the files to, you can enter a relative path here so to move the files out of the folder simply enter `..` to move them back one directory. Then to complete the move simply press enter or click the move button.

<figure><img src="/files/celN5U7mycfDLvRIefQu" alt=""><figcaption></figcaption></figure>

Finally you can delete the archive and folder on your server to free up space.

#### Final Configuration

You should ensure the start-up configuration (found in the `Startup` tab on your server control panel) before your bot is good to go. There are some notable configuration options.

You will see an option similar to `Bot <language> file` or `JAR FILE` or similar. This is the file that the server will start with. When developing your bot, you will have a main file that is used to start the code and import all other files, this is what you must enter here and make sure it is correct.

<figure><img src="/files/Sj99Jib1UYfuOBIDiXUD" alt=""><figcaption></figcaption></figure>

Additionally, if you are running a python or node.js server, you need to make sure you tell the server all modules (packages/libraries) that your code requires to be installed.

For node.js if you simply upload your `package.json` file, which should be generated when you installed the packages in your development environment, the server will use it to install all required dependencies.

For python you can either upload a `requirements.txt` file containing all modules to be installed or in the startup tab under `Additional Python packages` you can enter all modules you require with a space between them.

Your server should now be good to go!


# Cloning a Git repository on your server

You may want to run code directly pulled from a Git repository on your server. Our servers provide configuration options for doing this.

{% hint style="warning" %}
If you are having trouble cloning from a Git repository you can always download the files to your PC then upload them to the server.
{% endhint %}

To clone a Git repository on to your server you must configure the repository in the startup tab.

The first thing you must set is the repository address:

<figure><img src="/files/UnVmbFjIlef77jvNm8Du" alt=""><figcaption></figcaption></figure>

This is the URL that your repository is at, e.g. <https://github.com/yourname/reponame>.

Next you must set the install branch, for most people this is probably `master`. This is the production branch of your repository that should be pulled.

<figure><img src="/files/RfqcpwZSCgfWJsgyGriX" alt=""><figcaption></figcaption></figure>

#### If you repository is a private repository you must fill in the following variables

You must enter your username on the Git host in the Git username variable:

<figure><img src="/files/5uPUt54MLUKsWdCUyLAp" alt=""><figcaption></figcaption></figure>

And then you must enter your personal access token. Depending on the site you use to host your repository this can be found at the following links:

* [GitHub](https://github.com/settings/tokens)
* [GitLab](https://gitlab.com/-/profile/personal_access_tokens)

If you use a different service to host your repository you must create a personal access token with them.

#### Finally...

You must trigger the cloning so your server can pull from the repository every time it restarts. To do this firstly make sure there are no files on your server then on the settings page of your server click `Reinstall Server`.

<figure><img src="/files/Nusfsvz0nOJ77tJCKzTR" alt=""><figcaption></figcaption></figure>

Your repository should then clone!


# Connecting to your server's files with SFTP

SFTP is a popular protocol for connecting to a server's files and uploading/downloading files. It is a great way to manage files and upload your files from your PC.

You can use an SFTP client to connect to your server on bot-hosting.net and manage it's files.

## Downloading an SFTP client

The first thing you will need to do is download an SFTP client, which is used for connecting to the SFTP server and managing the files. This guide will use screenshots from WinSCP, but you can also use FileZilla. Download links:

* [WinSCP](https://winscp.net/eng/download.php) (Windows only)
* [FileZilla](https://filezilla-project.org/download.php?type=client)

Once downloaded, install the client you have chosen.

## Getting your SFTP connection details

To connect to the SFTP server you will need your connection details. On the control panel, go on the settings tab of your server

<figure><img src="/files/krsRkI5UDygsTqlqEvb5" alt=""><figcaption></figcaption></figure>

If you have an SFTP client installed you can click `Launch SFTP` and it will start your SFTP client with the details entered.

If your SFTP client does not launch for whatever reason, you can always start it yourself and copy and paste the connection details in (remember the number after the `:` at the end is the port, and the bit before it is the host, i.e. in this example `example.bot-hosting.net` is the host and `2022` is the port).

You will then need to get your SFTP password, which can be generated on the [settings page](https://bot-hosting.net/panel/settings) of the client panel.

Once all the details have been entered, you can connect. You may be prompted to accept the server's keys with a warning that you haven't connected to this server before, in which case you should click yes. The warning may look as follows:

<figure><img src="/files/CIg7umEfjgcvaLZf6L7F" alt=""><figcaption></figcaption></figure>

You should then connect and be able to manage your files, being able to copy files over from your PC and use the upload & download functions.


# Linking a domain to your server

This guide is for running an HTTP server that you want to link your domain to, through our reverse proxy.

To begin, you will need to get your numerical server ID (not to be confused with it's UUID). Your numerical server ID is a number. The easiest way to get this at the moment is on your server's manage server page where you can find the ID in the URL.

<figure><img src="/files/g3ESlprqDcHSLm8HJ4KD" alt=""><figcaption><p>Get your server ID in the url.</p></figcaption></figure>

Ok great, now you have your server ID you simply need to add a CNAME record pointing to `<your server ID>.site.bot-hosting.cloud`. For example with my ID, 8787, I would point it at `8787.site.bot-hosting.cloud`.

<figure><img src="/files/SVRU6AlyOBjV0wcTSwpO" alt=""><figcaption></figcaption></figure>

You can set the name to `@` to use your root domain name without any subdomain.

## Getting a TLS certificate

{% hint style="info" %}
If you want to be able to visit your site with HTTPS you need a TLS certificate.
{% endhint %}

We recommend you use Cloudflare for getting a TLS certificate, it's free and works great. Firstly if you have not already, you need to move your domain's name servers to Cloudflare by signing up at <https://dash.cloudflare.com> and setting it up.

Then you need to setup a CNAME record same as above but this time make sure the `Proxy status` option is checked.

<figure><img src="/files/IZcrqxXYwzoqdlVA9qsZ" alt=""><figcaption></figcaption></figure>

But this alone won't work. Since you are now passing the connection through a proxy, we can't figure out what target you're connecting to, so you need to add a `TXT` record as well. This TXT record should contain `bh-server=<your server ID>`.

<figure><img src="/files/Iwi7aOsYUaMpcpihrCJt" alt=""><figcaption><p>A TXT record for which server to target.</p></figcaption></figure>

Make sure you have SSL/TLS Encryption Mode set to flexible. Now you should be able to visit your domain through an HTTPS connection in your browser.

<figure><img src="/files/kIuaAF3zPfFZLjfYTEHG" alt=""><figcaption></figcaption></figure>


# Cannot find module / Cannot open file error on startup

This usually means you have forgotten to do one of two things:

1. You haven't set your main file in the startup tab, your main file is the file that is used to start your bot (in Node the file that you run with `node <your file>` and for Python `py <your file>.` Remember that if you unarchived your files in to a folder, you may need to move them out of that folder.
2. Your modules haven't installed. For node.js this usually means you've forgotten to upload your `package.json` and `package-lock.json` files in the home directory (`/home/container`) or you are getting an error upon your modules install which you should look for. For Python this usually means you haven't uploaded a `requirements.txt` file with each dependency on a new line (or you can specify your requirements in the startup tab under `Additional Dependencies` with a space between each one).


# Sqlite Installation Issues

Are you having issues with your Sqlite database dependency installing?

This is normally caused by the build uploaded to your server not being correct for it's operating system. This is a simple issue to resolve on `Node.js`, simply deleted the `node_modules` folder in your server's files and restart to force Sqlite to reinstall and download the correct build.


