Articles on: Bots & Applications

How to host a Discord bot

1. Prerequisites

Before deploying your bot, make sure you have:

  • Square Cloud Account: Create your account via the Registration Page (Email or GitHub).
  • Active Plan: A paid plan is required for hosting. Check the pricing here.



2. Source Code Preparation


For Square Cloud to run your bot correctly, it must be organized and contain the dependency definition file.


Python Example (discord.py)

Make sure you have a requirements.txt file in the root of your project:

discord.py


JavaScript Example (discord.js)

Make sure you have a package.json file in the root of your project:

{
"name": "my-discord-bot",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"discord.js": "^14.0.0"
}
}



3. Compression and Cleanup (Important)


A common mistake is trying to upload all project files, including cache folders or local dependencies. For a clean and fast deployment, you should create a .zip file containing only the essentials:


  • What to INCLUDE: .py or .js files, configuration files (.json, .txt), and the dependency file (requirements.txt or package.json).
  • What to EXCLUDE:
    • node_modules/ (Node modules folder)
    • __pycache__/ (Python cache)
    • .env (Environment variables will be configured in the dashboard)
    • .git/ or IDE files (such as .vscode/)



4. Deploying Your Bot


There are two main ways to upload your bot to Square Cloud:


Via Dashboard

  1. Access the Square Cloud Dashboard.
  2. Click on "New Application".
  3. Select the zip upload option.
  4. During upload, you will see fields to configure your Environment Variables (ENVs).


Via CLI

  1. Install the CLI:
npm i -g @squarecloud/cli
  1. Authenticate via the CLI: Get your API token on the My Account page by going to the Authentication section and requesting an API key. Next, authenticate in the CLI using the following command:
squarecloud auth login
  1. Create your configuration file: The configuration file, squarecloud.config or squarecloud.app, must be present in your project.
  2. Upload your project:
squarecloud upload
  • Or if you created a zip file:
squarecloud upload --file <path/to/zip>



5. Configuring Environment Variables (ENV)


Never leave your bot's token exposed directly in the code. Use Square Cloud's ENV system to keep your bot secure.


  • Dashboard Configuration: In the variables field, define the name (e.g., DISCORD_TOKEN) and the value (your token).
  • Pay attention to values: If your variable's value contains spaces or special characters (such as links or complex keys), use quotation marks to enclose the value.
    • Example: VARIABLE_NAME="Value with spaces or special characters"


In your code, access the variable like this:

  • Python: os.getenv('DISCORD_TOKEN')
  • JavaScript: process.env.DISCORD_TOKEN



6. Lifecycle and Monitoring


After uploading:

  1. Square Cloud will automatically detect the required runtime based on the chosen main file and install the dependencies.
  2. Follow the real-time Logs to check if the bot logged in successfully.

Updated on: 05/20/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!