Deploy a Discord.js Bot
Step-by-step guide to deploying a Discord.js (Node.js) bot on Daki Hosting.
This guide walks you through deploying a Discord.js bot on Daki Hosting — from creating your server to having your bot online and reading its token securely.
What you'll learn
- How to create a Node.js server for your bot
- How to upload your code
- How to configure the install command, startup command, and Docker image
- How to set your bot token securely using a
.envfile - How to start your bot and verify it works
Prerequisites
- A Daki account (Free Tier or paid) — see Create an Account
- A Discord bot with a bot token, created in the Discord Developer Portal
- Your bot's source code, including a
package.jsonwithdiscord.jsanddotenvas dependencies
Discord bots connect outbound to Discord's servers and do not require an inbound port. This means Discord bots work on both Free Tier and paid plans. If your bot also serves HTTP requests (e.g., for slash command interactions or webhooks), you will need a paid plan, as publicly accessible ports are only available on paid plans. See Network & Allocations.
Deployment
Create a Node.js server
- Log in to the Free Tier Dashboard at dash.daki.cc or the Billing Panel at billing.daki.cc.
- Create a new server and select the Node.js egg.
- Give your server a name (e.g.,
MyDiscordBot).
See Create Your First Server for the full walkthrough.
Access the Portal
Log in to the Portal via SSO (from the Credentials tab or your Billing Panel service page), or directly at portal.daki.cc. See Portal Overview.
Upload your bot's code
Option A — Upload as a ZIP (simplest):
- Compress your project folder into a
.zipfile locally. - In the Portal, go to the Files tab and click Upload.
- Right-click the
.zipand click Extract.
Option B — Use SFTP (no size limits): Connect using your SFTP credentials from the Settings tab and upload your folder directly. See File Manager.
Do not include your
node_modulesfolder in the upload — it will be installed automatically by the install command. Do include yourpackage.jsonandpackage-lock.json.- Compress your project folder into a
Configure the Startup tab
Open the Startup tab and configure all three fields:
1. Docker Image — Select the Node.js version your bot requires (e.g., Node.js 20 or Node.js 22). Node.js 20 LTS is a safe default if unsure.
2. Install Command — Set this to install your dependencies automatically:
Shellnpm install3. Startup Command — Set this to the command that launches your bot:
node index.js— if your entry file isindex.jsnode bot.js— if your entry file isbot.jsnpm start— if you have astartscript inpackage.json
You are free to adjust these commands to match your project structure.
See Startup Settings for a full explanation.
Add your bot token via a .env file
Your bot needs its Discord token to connect. Store it in a
.envfile on the server so it never ends up in your source code.- In the Files tab, click New File and name it
.env. - Add your token:
.env
BOT_TOKEN=your_discord_bot_token_here - Click Save.
In your bot code, load it with
dotenv:JavaScriptrequire('dotenv').config(); const { Client, GatewayIntentBits } = require('discord.js'); const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.once('ready', () => { console.log(`Logged in as ${client.user.tag}`); }); client.login(process.env.BOT_TOKEN);Make sure
dotenvis listed in yourpackage.jsondependencies so it gets installed by the install command.See Environment Variables for more details on using
.envfiles.- In the Files tab, click New File and name it
Start your bot
Click Start in the Console tab. A successful launch will print your bot's login confirmation:
TextLogged in as MyBot#1234!If you see errors instead, check the Troubleshooting guide.
Common Issues
Error: Cannot find module 'discord.js'
Your dependencies were not installed. Check that your package.json lists discord.js as a dependency, and that the install command is set to npm install in the Startup tab. Restart the server to trigger the install.
Error: Cannot find module 'dotenv'
Add dotenv to your package.json dependencies and restart the server to reinstall.
Error: An invalid token was provided
Your bot token in the .env file is incorrect or missing. Go to the Files tab, open .env, and verify the value. Make sure there are no extra spaces, quotes, or line breaks.
Bot starts but disconnects shortly after
This is usually caused by missing Gateway Intents. In the Discord Developer Portal, enable the required privileged intents (e.g., Message Content Intent) for your bot application, and ensure your code requests them.
Server crashes immediately on start
Open the Console tab and read the error. Common causes: wrong startup command (filename typo), wrong Node.js version, or missing node_modules. See Troubleshooting.
Next Steps
- Environment Variables — Full guide on
.envfiles and reading variables in code. - Keep Your Free Server Active — Watch ads to keep your Free Tier server alive.
- File Manager — Update your code files after making changes.