# Local Deployment

## Prerequisite

These are essentials that you need to host the bot on your local machine. We recommend Visual Studio Code as the Code Editor as it's generally easier to use.

&#x20;[![git](https://camo.githubusercontent.com/ad3ecc9b2ce67a1333ae9c3ace1430dd0730e9b1e9e5195334db167159dfc256/68747470733a2f2f62616467656e2e6e65742f62616467652f69636f6e2f6769743f69636f6e3d676974266c6162656c26636f6c6f723d353836354632267374796c653d666f722d7468652d6261646765267363616c653d312e34)](https://git-scm.com/downloads) [![Open in Visual Studio Code](https://camo.githubusercontent.com/842f94b10f76723e767df96fc5fe627e39ee3b56d1d2c5c8fa76a84edf879f7c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f56697375616c5f53747564696f5f436f64652d3538363546323f7374796c653d666f722d7468652d6261646765266c6f676f3d76697375616c25323073747564696f253230636f6465266c6f676f436f6c6f723d7768697465)](https://code.visualstudio.com/Download) [![node](https://camo.githubusercontent.com/dfc69d704694f22168bea3d84584663777fa5301dcad5bbcb5459b336da8d554/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4e6f64652e6a732d3433383533443f7374796c653d666f722d7468652d6261646765266c6f676f3d6e6f64652e6a73266c6f676f436f6c6f723d7768697465)](https://nodejs.org/en/download/)

| Title              | Download Link                            |
| ------------------ | ---------------------------------------- |
| Git                | <https://git-scm.com/downloads>          |
| Visual Studio Code | <https://code.visualstudio.com/Download> |
| Node.js            | <https://nodejs.org/en/download/>        |

## Step by Step Walkthrough

Clone this repository

```
git clone https://github.com/night0721/cath.exe
```

2\. Rename the [`.env.example` ](https://github.com/night0721/cath.exe/blob/main/.env.example)file into `.env`

3\. Create an application from Discord Developer's Portal then copy these things into the `.env` file.\
[![Open Discord Developer Portal](https://camo.githubusercontent.com/033078e2ec6e8c16e9ba47829125e2c356f859758565cc60da2dc7cb6132db86/68747470733a2f2f62616467656e2e6e65742f62616467652f69636f6e2f646973636f72643f69636f6e3d646973636f7264266c6162656c3d446576656c6f706572253230506f7274616c26636f6c6f723d353836354632267374796c653d666f722d7468652d6261646765)](https://discord.com/developers/applications)

* **Bot Token**
* **Application ID** (Client ID)
* **Client Secret**

4\. To view the logs, Create 5 Channels & 5 Webhooks in a **Discord Server** corresponding to these logs.

* **Server Log** (Log new Server Added/Premium Server)
* **Error Log** (Log Unhandled Rejection Error)
* **Ready Log** (Log when bot online)
* **Command Log** (Log command usage)
* **DM Log** (Log when someone send DM to Bot)

> You can also just use one Channel & one Webhook for everything but it will be really inconvenient.

![](https://camo.githubusercontent.com/36c655567729b7414e71889a19489620e2964c1ecb2579cff1ec2ad3d29ec6f7/68747470733a2f2f6d656469612e646973636f72646170702e6e65742f6174746163686d656e74732f3534303231383430303431333138383131362f3836373739373436343136393730393636312f756e6b6e6f776e2e706e67)

5\. One by one paste the Webhook URL in a web browser & copy the **ID** & the **TOKEN** and paste it in the corresponding fields in the `.env` file.

6\. Setting up Mongo DB

{% content-ref url="local/mongo-db-setup" %}
[mongo-db-setup](https://thunder75.gitbook.io/nyx/deployment/local/mongo-db-setup)
{% endcontent-ref %}

7\. Setup a **Spotify Application.**

{% content-ref url="local/spotify-setup" %}
[spotify-setup](https://thunder75.gitbook.io/nyx/deployment/local/spotify-setup)
{% endcontent-ref %}

8\. Go back to the Discord Developer's Portal in the OAuth2 tab, Select `BOT` in the **Scopes Section** & Select `ADMINSTRATOR`from the **BOT PERMISSIONS** Section.

9\. Copy the URL and by using the URL invite the bot to a server.

10\. After this, you need to install all dependencies by using this command. This will takes a few minutes.

```
npm i
```

11\. Now, to start the bot use this command in the terminal.

```
node .
```
