# How to Deploy TGVCBot (<=v0.2.5) in a Ubuntu VPS

I wrote [TGVCBot](https://github.com/ArnabXD/TGVCBot) , Telegram bot+userbot to play music from JioSaavn and YouTube in the group voice chats. Here I am gonna explain how to make it work in your own VPS.

%[https://github.com/ArnabXD/TGVCBot]


## Deploy TGVCBot

First SSH into your VPS and upgrade the packages

```bash
sudo apt-get update
```
```bash
sudo apt-get upgrade
```

### [Install NodeJS Latest](https://github.com/nodesource/distributions)

```bash
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
```
```bash
sudo apt-get install -y nodejs
```

### Install Yarn and PM2

```bash
sudo npm i -g yarn pm2
```

### Install FFMPEG & Git

```bash
sudo apt-get install git ffmpeg -y
```

### Clone The Repo & Install Dependencies of TGVCBot

```bash
git clone https://github.com/ArnabXD/TGVCBot.git
cd TGVCBot
yarn
yarn build
```

### Setup ENV Variables

Knowing the Variables

| Name         | Description                                                                            | Required |
| ------------ | -------------------------------------------------------------------------------------- | -------- |
| API_ID       | Your telegram app's API_ID. Get it from https://my.telegram.org/apps                   | True     |
| API_HASH     | Your telegram app's API_HASH. Get it from https://my.telegram.org/apps                 | True     |
| BOT_TOKEN    | Bot Token from [@BotFather](https://telegram.dog/BotFather)                            | True     |
| LOG_CHANNEL  | Chat ID of Channel/Group to keep logs. (Make sure to add VC User and Bot to the group) | True     |
| SESSION      | GramJS/Telethon session string of the VC User. [Session Gen](https://ssg.rojser.best)  | True     |
| MAX_DURATION | Set maximum duration of the stream. Default: `36000` seconds                           | False    |
| THUMBNAIL    | Direct link for default thumbnail (used if audio has no thumbnails).                   | False    |

Simply copy the `.env.sample` to `.env`

```bash
cp .env.sample .env
```

Now modify the `.env` with your values. Use your preferred text editor 

### Run The Bot

Once you followed all the previous, now it's time to run the bot. I will use `pm2` to run the bot.

```bash
pm2 start npm --name "tgvc" -- run start --exp-backoff-restart-delay=1000
```

this will auto-restart bot on crashes.

With PM2 we can start the bot automatically on VPS reboot too.

```bash
# save the pm2 list
pm2 save

# get startup command
pm2 startup
```
this will return a command. Execute that to start bot on VPS startup
