skipToMainContent
Loading AshHost...

How to Host a 24/7 Discord Bot (Node.js & Python)

Yazdır

Running a Discord bot on a home computer or free tier host often leads to rate limits, sleep timeouts, and unexpected downtime. Ash Host provides containerized Discord bot hosting with continuous uptime, automated crash restarts, and instant package installation for both Node.js and Python bots.

Security Rule: Never hardcode your Discord bot token inside your public code repository or configuration files. Always use the Environment Variables / Startup tab or a .env file.

Method A: Hosting a Node.js Bot (discord.js)

1. Prepare Your Bot Files

Ensure your project directory contains your main entry file (usually index.js or bot.js) and a valid package.json file defining your dependencies.

{
  "name": "my-discord-bot",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "discord.js": "^14.14.0",
    "dotenv": "^16.3.1"
  }
}

2. Upload Files to Ash Host Panel

  1. Log in to the Ash Host Game Panel and select your bot container.
  2. Go to the Files tab.
  3. Upload your project files (e.g., index.js, package.json, commands folder). Do not upload the node_modules folder; the panel will install dependencies automatically.

3. Configure Startup Settings

  1. Navigate to the Startup tab on the left menu.
  2. Verify the Main File field is set to match your entry point (e.g., index.js).
  3. Verify the Node.js Version matches your code requirements (Node 18 or Node 20 recommended for discord.js v14).

4. Install Dependencies & Start

  1. Go to the Console tab and click Start.
  2. The container will automatically execute npm install, download required packages, and launch your bot.
  3. Check the console log to verify your bot has logged in successfully:
    Ready! Logged in as MyBot#1234

Method B: Hosting a Python Bot (discord.py / nextcord)

1. Prepare Your Python Files

Your bot directory must contain your entry file (e.g., main.py or bot.py) and a requirements.txt file listing all required Python libraries:

discord.py>=2.3.0
python-dotenv>=1.0.0
aiohttp>=3.9.0

2. Upload and Run

  1. Go to the Files tab in the Ash Host Game Panel.
  2. Upload main.py, requirements.txt, and your bot assets.
  3. Go to the Startup tab and ensure the Main File is set to main.py.
  4. Return to the Console tab and click Start. The panel will run pip install -r requirements.txt inside your virtual container and launch the bot.

Managing Bot Tokens Securely

To update or rotate your bot token without editing script files:

  1. Go to the Files tab and create a file named .env.
  2. Add your bot credentials:
    DISCORD_TOKEN=MTAyNDU5...your_actual_token_here...
    CLIENT_ID=123456789012345678
  3. In your Node.js or Python script, reference the token via process.env.DISCORD_TOKEN or os.getenv('DISCORD_TOKEN').

Frequently Asked Questions

Will my bot shut down when I close my browser?
No. Ash Host bot containers run inside isolated Docker instances that operate 24/7 on our enterprise servers, independent of your local machine.

What happens if the bot encounters an uncaught exception?
Ash Host containers are set to auto-restart on unexpected crashes, minimizing bot downtime.

Need affordable, dedicated hosting for your Discord bot? Check out our Ash Host 24/7 Bot Hosting Plans with instant activation, automated backups, and low resource overhead.

Bu cevap yeterince yardımcı oldu mu?

Powered by WHMCompleteSolution

⚡ Trusted by 5,000+ Customers

India's Most Trusted Game Server Hosting

Discord bots, FiveM, SA-MP, Minecraft & more — powered by enterprise infrastructure. 99.9% uptime, 24/7 support, rated 4.9★ on Trustpilot.

5K+Customers
99.9%Uptime
4.9★Trustpilot
24/7Support