NEW 📢 Limited launch offer: up to 70% off your first month on every game!See plans

How to host a Bun Discord bot

Discord bot hostingUpdated Oct 29, 20265 min read

Bun runs JavaScript and TypeScript bots with no build step, and discord.js works on it. To run one:

  1. Switch the type: on the Bot page, pane Code, click Change what runs next to Runtime and pick Bun Bot.
  2. Upload your files with package.json in Files, without node_modules.
  3. Check the Entry file (index.ts by default) on the Bot page, pane Code.
  4. Paste your token on the Discord pane and click Connect.
  5. Press Start and watch Console.

1. Switch the type to Bun Bot

On the Bot page, pane Code, click Change what runs next to Runtime and pick Bun Bot. On a computer, the type label at the top of the page (for example Node.js Bot) opens the same dialog. Leave Delete my existing files and start clean. unticked to keep your files. Same plan, same price. See How to switch your bot to another language.

2. Add your code

Upload your .ts or .js files and package.json in Files (zip a folder, upload, tick it, Unzip). Leave out node_modules. Or choose Git repository as the source on the Code pane: How to deploy and update your Discord bot from GitHub.

3. Set how it runs

On the Bot page, pane Code, card How it runs:

  • Entry file: index.ts by default. Any .ts or .js file works, for example src/bot.ts.
  • Runtime: Bun (latest), or Bun canary (unstable) if you need a feature that is not released yet.
  • Packages: extra packages added with bun add at the next start after you change them, separated by spaces.

The How it runs card of a Bun bot with Entry file index.ts and Runtime Bun (latest).

4. Paste the token and start

On the Discord pane, paste the token and click Connect. Press Start and open Console. The server runs bun install when a package.json exists, prints [PlayNHost] Starting your bot, and runs bun run on your entry file. Later starts install again only when Packages, package.json, the lockfile or the Bun version changed, when node_modules is missing, or once a day; otherwise the console says [PlayNHost] Packages are up to date.

A minimal Bun bot with discord.js

package.json

{
  "name": "my-bun-bot",
  "private": true,
  "dependencies": {
    "discord.js": "^14"
  }
}

index.ts

import { Client, Events, GatewayIntentBits } from 'discord.js';

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.once(Events.ClientReady, (c) => {
  console.log(`Logged in as ${c.user.tag}`);
});

client.login(process.env.DISCORD_TOKEN);

Bun reads the token with process.env.DISCORD_TOKEN or Bun.env.DISCORD_TOKEN. Printing Logged in as turns the chip on Overview to Online in Discord.

Console lines you may see

LineWhat to do
[PlayNHost] Your bot is not set up yet: the main file index.ts was not found.Upload your files, or set Entry file to the real name and folder.
[PlayNHost] bot.py is a Python file, but this server runs Bun (JavaScript).Your code is Python. Click Change what runs and pick Python Bot, keeping your files.
[PlayNHost] index.ts starts with ```, a Markdown code fence copied together with the code.Open the file in Files, delete the first and last ``` lines, save, start again.
[PlayNHost] Bun could not install everything in package.json. Starting with the packages already installed.A name or version in package.json is wrong. Bun's error just above names it.
[PlayNHost] Some packages in Bot page, Code, Packages could not be installed.Check the spelling in Packages and that names are separated by spaces.
Banner A package your code needs is missingYour code imports a package that is not installed. Add it to package.json or Packages, then restart.

The wrong-language, fence and package lines come from the start script of servers installed or reinstalled since 28 October 2026. On an older server, click Reinstall at the bottom of the Code pane once: your files stay.

Good to know

Already hosting your bot somewhere else? Move it to us

OUR LATEST BLOGS