Go to the quickstart repository and click on the Use this template button.
bun install
Rename the .env.example file to .env and set your Discord bot token (Discord Developer Portal):
TOKEN=your_discord_bot_token
bun run start
Set up a new djs-core project from scratch with complete control over your project structure.
Create a new Bun project:
bun init
This creates a basic package.json and initializes your project structure.
Install djs-core packages:
bun i -D @djs-core/dev
bun i @djs-core/runtime
@djs-core/dev is a dev dependency providing build tools and CLI commands@djs-core/runtime is the runtime library containing the framework logicdiscord.js installed: bun i discord.jsAdd the following scripts to your package.json:
{
"scripts": {
"dev": "djs-core dev",
"build": "djs-core build",
"start": "djs-core start"
}
}
dist/ folder for productiondist/ folder (use after build)Create a djs.config.ts file in your project root:
import type { Config } from "@djs-core/dev";
if (!process.env.TOKEN) {
throw new Error("TOKEN environment variable is required");
}
export default {
token: process.env.TOKEN,
servers: ["YOUR_GUILD_ID"],
} satisfies Config;
[] for global commands (takes up to 1 hour to propagate)..env file and add .env to your .gitignore.Create a .env file in your project root:
TOKEN=your_discord_bot_token_here
Make sure to add .env to your .gitignore:
.env
node_modules/
dist/
Create the directory structure and your first command:
import { Command } from "@djs-core/runtime";
export default new Command()
.setDescription("Ping the bot")
.run(async (interaction) => {
await interaction.reply("Pong!");
});
src/interactions/commands/ping.ts becomes /ping in Discord.Run your bot in development mode:
bun run dev
Your bot should now be online and the /ping command should be available in Discord!
Now that your bot is set up, here's what to explore next: