Introduction
To develop and host a Discord bot on Square Cloud, it’s essential to follow a structured sequence of configurations and prerequisites. This technical guide will cover the entire process, from initial setup to production deployment.Prerequisites
- Square Cloud Account: Register through the signup page using your email.
- Active plan: Ensures dedicated resources and optimized performance for your application. Check our available plans and choose the most suitable for your needs.
Create the project
You need a Discord account to create and manage bots. If you don’t have one, create it on the official Discord website.Bot application on Discord
Create the application
Access the Developer Portal and click “New Application”. Define a name for your bot and click “Create” to create the application.

Generate the token
After creating the application, navigate to the “Bot” tab and click “Reset Token” to generate the authentication token. Copy it: you will set it as an environment variable on Square Cloud, never in your code.

Turn on the privileged intents
The example bot reads the text of messages, so it needs the Message Content Intent. Stay in the “Bot” tab, scroll down to “Privileged Gateway Intents” and turn on Message Content Intent. This example doesn’t need the other two privileged intents (Presence and Server Members).

Develop the bot
Write the bot with discord.js (Node.js) or discord.py (Python):- Discord.js (Node.js)
- Discord.py (Python)
- Verify that Node.js is installed on your system. If not, download it from the official Node.js website.
- Initialize a new Node.js project:
Terminal
- Install the discord.js library:
Terminal
- Create a JavaScript file (e.g.,
index.js) and add the following code to create a basic Discord bot:
index.js
Events.ClientReady ("clientReady"). The old "ready" name is deprecated.Configure Square Cloud
Create asquarecloud.app file at the root of your project, next to your main file. It tells Square Cloud how to run your bot:
MAINis the file Square Cloud runs, andMEMORYis the bot’s RAM in MB. Bots need at least 256 MB; 512 MB leaves room to grow.AUTORESTART=truestarts the bot again if it crashes. See how auto restart works.- There is no
SUBDOMAIN: a bot doesn’t serve web pages.
Set the bot token
Your code reads the token from theDISCORD_TOKEN environment variable, so the token never goes into your files. Set it in one of these ways:
- Dashboard: on the upload page, open Advanced configuration and add a variable named
DISCORD_TOKENwith your token as the value. For a bot that is already deployed, add it on the application’s Environment Variables page and restart the bot. - CLI: right after you upload the bot (see Deploy and verify), set it with
squarecloud app env setand restart the bot:
What goes in the ZIP
- Your main file (
index.jsormain.py) and your other source files. package.jsonorrequirements.txt.squarecloud.app.
node_modules, .venv and __pycache__: Square Cloud installs your dependencies when the bot starts.
Deploy and verify
Create the ZIP described above, then upload it:Via dashboard
1
Access the Upload Page
Access the upload page and upload your project zip file.
2
Configure Your Environment
After uploading your zip, you will need to configure the name, main file or runtime environment and other settings for your project.
If you are uploading a web project, make sure to select “Web Publication” and set a subdomain to your project.
If you are uploading a web project, make sure to select “Web Publication” and set a subdomain to your project.
3
Deploy Your Project
Finally, click on the “Deploy” button to host your project on Square Cloud.
After deployment, you can monitor your project’s status and logs from the dashboard.
After deployment, you can monitor your project’s status and logs from the dashboard.

4
Confirm Your App Is Live
Your first deploy usually takes less than a minute. In the dashboard, wait for your application status to show as running and check the logs for any startup errors.
If you deployed a website or API, open
If you deployed a website or API, open
https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
Via CLI
To use this method, your project needs a configuration file namedsquarecloud.app at its root. It tells Square Cloud how to run your application.
Configuration file guide
Learn how to create the
squarecloud.app configuration file that defines your application’s environment.1
Install the CLI
Install the Square Cloud CLI. If you already have it, run the same command to update it:
2
Log In
Run the command below. It opens your browser: approve the login there and the CLI is ready. There is no API key to copy. For scripts and CI, see CLI authentication.
3
Upload Your Project
From your project folder, run the command below. The CLI zips the current folder, leaving out what To upload a zip you created yourself, pass it with
squarecloud.ignore lists, and uploads it:--file:4
Confirm Your App Is Live
Your first deploy usually takes less than a minute. Check your application status and logs directly from the terminal:If you deployed a website or API, open
https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
Invite the bot to your server
To send the bot a command, add it to a Discord server:- Access the Developer Portal and select your bot.
- Navigate to the “OAuth2” tab and go to “OAuth2 URL Generator”.
- Under “Scopes”, check the “bot” option.
- Under “Bot Permissions”, check only what the example needs: View Channels, Send Messages and Read Message History. Avoid Administrator: bots rarely need it, and a leaked token would then control your whole server.
- Copy the generated URL, open it in your browser and add the bot to your server. The URL looks like this:
68608 is the sum of those three permissions. Replace YOUR_CLIENT_ID with your application’s ID, shown on the “General Information” tab. If you add commands that need more permissions, generate a new URL with them checked.
Then send !hello in a channel the bot can see. It replies with Hello!.

Common errors
An invalid token was provided
The logs showError [TokenInvalid]: An invalid token was provided. (discord.js) or discord.errors.LoginFailure: Improper token has been passed. (discord.py). The DISCORD_TOKEN variable is missing or holds an old token. Copy the current token from the “Bot” tab, set it again and restart the bot. With discord.py, a KeyError: 'DISCORD_TOKEN' means the variable is not set at all.
Used disallowed intents
The logs showError [DisallowedIntents]: Privileged intent provided is not enabled or whitelisted. (discord.js) or discord.errors.PrivilegedIntentsRequired (discord.py). The code asks for the Message Content Intent, but it is off in the Developer Portal. Turn it on in the “Bot” tab, as in Bot application on Discord, then restart the bot.
The bot is online but doesn’t answer !hello
Check that the bot can view and send messages in that channel, and that the Message Content Intent is on: without it, the bot receives messages with empty text.
For more messages and fixes, see Discord bot errors.
Next steps
Discord bot errors
Fix an invalid token, missing intents and other common errors.
Environment variables
Manage your bot’s token and other secrets.
Lavalink server
Host a Lavalink server to play music in your bot.

