multi-dc
v0.1.9
Published
Run multiple discord.js bots from separate folders in one Node.js process.
Maintainers
Readme
multi-discord.js
Run multiple discord.js bots in a single Node.js process, where each bot lives in its own folder with its own code.
Features
- Run multiple bots from one config file.
- Works with JavaScript and TypeScript bot files.
- CLI starter to scaffold a 3-bot project.
- Uses latest
discord.jsv14 in templates.
Install
npm install multi-dc discord.jsQuick Start
npx multi-dc init --dir ./my-bots --lang ts
cd my-bots
npm install
npm run devSet env vars before running:
TKN1TKN2TKN3
Config
Create multi-discord.config.ts or multi-discord.config.js:
import { defineMultiBotConfig } from "multi-dc";
export default defineMultiBotConfig({
envFile: ".env",
botsBasePath: "bots",
onError: "continue",
bots: [
{ name: "bot1", path: "bot1", entry: "src/bot.ts", tokenEnv: "TKN1" },
{ name: "bot2", path: "bot2", entry: "src/bot.ts", tokenEnv: "TKN2" },
{ name: "bot3", path: "bot3", entry: "src/bot.ts", tokenEnv: "TKN3" },
],
});Optional config fields:
envFile: Path to a.envfile (relative to config file location or absolute).botsBasePath: Base folder for all botpathvalues.
Each bot module should export createBotClient or a default function returning a discord.js Client.
CLI
multi-dc run [--config <file>]
multi-dc init [--dir <folder>] [--lang ts|js]