A TypeScript template for creating Discord bots with discord.js
-
Clone the repo and install dependencies:
git clone https://github.com/BurakYs/bot-template.git cd bot-template pnpm install cp .env.template .env -
Add your bot token to the
.envfile -
Register slash commands:
pnpm register-commands
-
Start the bot:
pnpm start
- Add new languages by:
- Creating a JSON file in
src/localizations - Updating the
supportedLanguagesarray insrc/config.ts
- Creating a JSON file in
- Organize commands in subfolders under
src/commands - See
types/index.d.tsfor config structure - Example of a subcommand-specific config:
defineCommand({ data: new SlashCommandBuilder() /* ... */, config: { guildOnly: true, premiumOnly: { '*': false, // Default 'subcommandName': true, // Only applies to "subcommandName" 'subcommandGroupName subcommandName': true // Only applies to "subcommandName" in "subcommandGroupName" } }, run: async ({ client, interaction }) => { // command logic } });
interaction.success()- Sends a success messageinteraction.error()- Sends an error messageinteraction.translate()- Translates a key using the current language
This project is licensed under the MIT License.