Skip to main content
Version: 1.x

Category Directory

Category directories are special directories inside src/app/commands, with (categoryName) as their name.

It is primarily used to group related commands together. This is useful for organizing your commands into logical groups, making it easier to manage and maintain your code. You can even nest multiple category directories to create a hierarchy of commands. This can then be used across your application in places such as middlewares, plugins, or even other commands through your commandkit instance.

Example structure

.
├── src/
│ ├── app/
│ │ ├── commands/
│ │ │ ├── (Fun)/
│ │ │ │ ├── (Jokes)/
│ │ │ │ │ ├── random-joke.ts
│ │ │ │ │ └── dad-joke.ts
│ │ │ │ ├── 8ball.ts
│ │ │ │ ├── cat.ts
│ │ │ │ └── dog.ts
│ │ │ └── (Moderation)/
│ │ │ ├── timeout.ts
│ │ │ ├── kick.ts
│ │ │ └── ban.ts
│ │ └── events/
│ │ └── clientReady/
│ │ └── log.ts
│ └── app.ts
├── .env
├── .gitignore
├── commandkit.config.ts
├── package.json
└── tsconfig.json

[!NOTE] Transparent Categories vs Subcommand Hierarchy: Folders using parenthesis (Category) strictly serve to group handlers mentally and apply transparent middlewares. They do not change the execution slash command (/ban). If you are designing comprehensive setups combining sub-commands, you should establish a Root Command directory using square brackets [commandName]. Read more in the Subcommand Hierarchy Guide.