A TypeScript template for building Discord bots with discord.js and Bun.
- Clone the repo and install dependencies:
git clone https://github.com/bur4ky/bot-template.git
cd bot-template
bun install
cp .env.example .env-
Fill in
.env. -
Register slash commands:
bun register- Start the bot:
bun startEach command supports per-subcommand config overrides:
defineCommand({
data: new SlashCommandBuilder() /* ... */,
config: {
category: "Bot",
guildOnly: true,
disabled: {
"*": false,
subcommandName: true,
"subcommandGroupName subcommandName": true,
},
},
run: async ({ client, interaction }) => {
/* ... */
}
});Important
Do not set descriptions in SlashCommandBuilder() when the command is localized.
The command loader already sets the default description using the default language and applies localized names, descriptions etc automatically.
Translations live in src/localizations. To add a new language:
- Add the runtime translation file at
src/localizations/<code>.json. - Add the command registration file at
src/localizations/commandData/<code>.json. - Add the locale mapping in
src/shared/config.ts.
Important
Keep the language codes in supportedLanguages aligned with the filenames in both localization folders.
These helpers are added to every interaction:
interaction.success(message | options)sends a success embed.interaction.error(message | options)sends an error embed.interaction.t(key, options)translates a key using the interaction's locale.