How to deploy a discord.js bot to Schokr
Upload a discord.js bot to an Schokr Node.js server, install dependencies from package.json, set the startup file and keep it running 24/7.
Updated · 2 min read
To deploy a discord.js bot on Schokr, create a server from the Node.js template, upload your code (without node_modules) through the file manager, add a .env file with your token, set the main file in your server's Startup settings and start the server.
Before you start
Make sure the bot runs on your own computer first. If it doesn't work locally, it won't work on Schokr either. A typical project looks like this:
my-bot/
index.js
package.json
package-lock.json
.env
commands/
Your package.json must list every package the bot uses under dependencies:
{
"name": "my-bot",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"discord.js": "^14.16.0",
"dotenv": "^16.4.0"
}
}
If a package only lives in your local node_modules and isn't in package.json, the server won't have it and you'll get "Cannot find module". See fixing module not found errors.
1. Create the server
- In the Schokr console, create a server from the Node.js template.
- Give it 256 to 512 MB of memory to start. You can raise it later from your team's pool.
- Pick a location. Any location works for Discord; choose one near any database or API your bot talks to.
2. Upload your code
- Open the server's file manager.
- Upload your files and folders. You can upload a zip and extract it in the file manager, which is faster for many files.
- Do not upload
node_modules. It's large, and native packages built on Windows or macOS won't run on the Linux server.
3. Add your token
Create a file named .env in the server's root folder with the file manager:
DISCORD_TOKEN=your-token-here
Load it at the top of your entry file with require('dotenv').config();. More options are in storing your token safely.
4. Set the startup file
Open your server's Startup settings and set the main file (or startup command) to your entry point, for example index.js. If your bot is in a subfolder or uses a different file such as src/bot.js, enter that path relative to the server root.
5. Install dependencies and start
Start the server and watch the console. The Node.js template is set up to install the packages listed in package.json when the server starts, so you should see npm install output before your bot's own logs. Then you should see your ready message, for example Logged in as MyBot#1234.
If you don't see packages being installed, check your server's Startup settings for a variable that controls package installation, and make sure package.json is in the server root (not inside a subfolder).
6. Confirm it works
- The bot shows as online in Discord.
- A test command gets a reply.
- The Resources view shows stable memory use.
Updating later
Upload the changed files, then restart the server. If you added a new package, add it to package.json first so it installs on the next start. See updating your bot's code.
Troubleshooting
- Bot starts then stops: read the error in the console. See reading bot logs.
- "Used disallowed intents": see privileged intents.
- "An invalid token was provided": see invalid token errors.