djs-core is a lightweight TypeScript framework built on top of discord.js, fully compatible with Node.js (≥ 18, ESM) and optimized for Bun for top-notch performance.
Key features:
- A CLI to scaffold slash-commands and event listeners in seconds.
- Development mode with hot-reload and automatic slash-command deployment.
- A build system that bundles & minifies your bot for production (optional Docker output).
- A minimal API to declare slash-commands and listeners without boilerplate.
⚡️ Runs on Bun (≥ 1.2) or Node.js (≥ 18, ESM). Bun is recommended for faster installs and startup times, but everything works fine on standard Node.
- Installation
- Getting started
- CLI reference
- Configuration
- Complete example
- Build & deploy
- Contributing
- License
bun add djs-core discord.jsdiscord.js is declared as a peer-dependency, therefore you must install it yourself.
Create a fresh project:
bun init my-bot
cd my-botAdd a djsconfig.ts file at the project root:
import { GatewayIntentBits } from "discord.js";
export default {
token: process.env.TOKEN ?? "", // provided via .env
intents: [GatewayIntentBits.Guilds], // adjust to your needs
guildIds: ["123456789012345678"], // optional: instant guild deployment
} as const;Scaffold your first command:
bunx djs-core generate:command --name ping --description "Replies with Pong!"Start the bot in development mode (hot-reload):
TOKEN=YourToken bunx djs-core devType /ping in Discord → the bot replies « Pong! 🏓 ».
| Command | Description |
|---|---|
generate:command |
Create a slash-command skeleton inside src/commands/. |
generate:event |
Create a Discord event listener inside src/events/. |
dev [path] |
Launch the bot in development mode (with hot-reload). |
build [path] |
Bundle the bot for production (+ --docker option). |
New files are automatically opened in your editor if the EDITOR or VISUAL environment variable is set.
bunx djs-core generate:command -n avatar -d "Shows a user avatar"import { Command } from "djs-core";
export default new Command()
.setName("avatar")
.setDescription("Shows a user avatar")
.addUserOption((option) => option.setName("user").setDescription("The user to show the avatar of").setRequired(false))
.run((_client, interaction) => {
const user = interaction.options.getUser("user") ?? interaction.user;
interaction.reply(user.displayAvatarURL());
});| File | Purpose |
|---|---|
.env |
Stores secrets (Discord token, API keys…). Ignored by Git. |
.env.template |
Sample .env file committed to document required variables. |
djsconfig.ts/js |
Main bot configuration (token, intents, guildIds…). |
Tip: In development mode,
djs-coreautomatically loads variables from.envif present at the project root.
A ready-to-run example bot is available in examples/playground.
cd examples/playground
cp .env.template .env # put your TOKEN in .env
TOKEN=YourToken bunx djs-core dev .bunx djs-core build # produces dist/ ready for BunOptions:
--docker– add a minimalDockerfiletodist/(FROMoven/bun:alpine).
The output directory (dist/) contains:
index.js– ES2020 minified bundle.package.json– production dependencies +startscript.Dockerfile(if--dockerwas used).
Deploy the folder to your host of choice:
cd dist
bun install --production
bun startPRs are welcome! To hack on the library itself:
bun install
bun run dev # tests/linters will be added soonBefore opening a pull-request:
- Ensure
bun test(coming soon) passes. - Keep the documentation up-to-date.