Exclusive Metin2 game shield on FreeBSD: Automatic siege mode, VIP list, and whitelist from your dashboard. See how it works
Create a server

Guide

How to Run a Discord Bot on a VPS

A Discord bot on a VPS stays online 24/7. Minimum: Node.js (or Python), the token outside code, and a process that survives SSH.

Steps

  1. Install Node.js LTS and create the project:

    sudo apt update
    sudo apt install -y nodejs npm
    mkdir -p ~/discord-bot && cd ~/discord-bot
    npm init -y && npm install discord.js
  2. Store the token in an env file (do not commit it):

    nano ~/discord-bot/.env
    DISCORD_TOKEN=your_secret_token
  3. Start the bot (example) and keep it in tmux:

    tmux new -s discordbot
    cd ~/discord-bot && node index.js

Tips

  • Revoke and regenerate the token if it leaks.
  • For production use a systemd unit with Restart=always.

ext step

A stable VPS for bots and games: Browse game servers.

Related guides