Setup CommandKit
- CommandKit requires at least Node.js v24
- This documentation assumes that you have a basic understanding of how to use discord.js. If you are new to discord.js, we recommend you to read the discord.js guide first.
The quickest way to setup a new CommandKit project is to use the
create-commandkit
CLI. To get started, run the following command in
your terminal:
- npm
- Yarn
- pnpm
- Bun
npm create commandkit@latest
yarn create commandkit
pnpm create commandkit
bunx create-commandkit
This will start the CLI in an interactive mode. You can follow the prompts to setup your project.
Available Examples
CommandKit comes with several pre-built examples to help you get started quickly. You can list all available examples using:
- npm
- Yarn
- pnpm
- Bun
npm create commandkit@latest --list-examples
yarn create commandkit --list-examples
pnpm create commandkit --list-examples
bunx create-commandkit --list-examples
Using Examples
You can create a project from any example using the --example
flag:
- npm
- Yarn
- pnpm
- Bun
# Create a basic TypeScript bot
npm create commandkit@latest --example basic-ts
# Create a basic JavaScript bot
npm create commandkit@latest --example basic-js
# Create a Deno TypeScript bot
npm create commandkit@latest --example deno-ts
# Create a bot without CLI integration
npm create commandkit@latest --example without-cli
# Create a basic TypeScript bot
yarn create commandkit --example basic-ts
# Create a basic JavaScript bot
yarn create commandkit --example basic-js
# Create a Deno TypeScript bot
yarn create commandkit --example deno-ts
# Create a bot without CLI integration
yarn create commandkit --example without-cli
# Create a basic TypeScript bot
pnpm create commandkit --example basic-ts
# Create a basic JavaScript bot
pnpm create commandkit --example basic-js
# Create a Deno TypeScript bot
pnpm create commandkit --example deno-ts
# Create a bot without CLI integration
pnpm create commandkit --example without-cli
# Create a basic TypeScript bot
bunx create-commandkit --example basic-ts
# Create a basic JavaScript bot
bunx create-commandkit --example basic-js
# Create a Deno TypeScript bot
bunx create-commandkit --example deno-ts
# Create a bot without CLI integration
bunx create-commandkit --example without-cli
CLI Options
The CLI supports various options for customization:
- npm
- Yarn
- pnpm
- Bun
# Skip prompts and use defaults
npm create commandkit@latest --yes
# Use a specific package manager
npm create commandkit@latest --use-pnpm
npm create commandkit@latest --use-yarn
npm create commandkit@latest --use-bun
npm create commandkit@latest --use-deno
# Skip dependency installation
npm create commandkit@latest --skip-install
# Skip git initialization
npm create commandkit@latest --no-git
# Create in a specific directory
npm create commandkit@latest my-bot
# Use a custom GitHub repository
npm create commandkit@latest --example "https://github.com/user/repo"
# Skip prompts and use defaults
yarn create commandkit --yes
# Use a specific package manager
yarn create commandkit --use-pnpm
yarn create commandkit --use-yarn
yarn create commandkit --use-bun
yarn create commandkit --use-deno
# Skip dependency installation
yarn create commandkit --skip-install
# Skip git initialization
yarn create commandkit --no-git
# Create in a specific directory
yarn create commandkit my-bot
# Use a custom GitHub repository
yarn create commandkit --example "https://github.com/user/repo"
# Skip prompts and use defaults
pnpm create commandkit --yes
# Use a specific package manager
pnpm create commandkit --use-pnpm
pnpm create commandkit --use-yarn
pnpm create commandkit --use-bun
pnpm create commandkit --use-deno
# Skip dependency installation
pnpm create commandkit --skip-install
# Skip git initialization
pnpm create commandkit --no-git
# Create in a specific directory
pnpm create commandkit my-bot
# Use a custom GitHub repository
pnpm create commandkit --example "https://github.com/user/repo"
# Skip prompts and use defaults
bunx create-commandkit --yes
# Use a specific package manager
bunx create-commandkit --use-pnpm
bunx create-commandkit --use-yarn
bunx create-commandkit --use-bun
bunx create-commandkit --use-deno
# Skip dependency installation
bunx create-commandkit --skip-install
# Skip git initialization
bunx create-commandkit --no-git
# Create in a specific directory
bunx create-commandkit my-bot
# Use a custom GitHub repository
bunx create-commandkit --example "https://github.com/user/repo"
Project structure
By using the CLI to create a base project, you should get a file tree that looks something like this:
.
├── src/
│ ├── app/
│ │ ├── commands/
│ │ │ └── ping.ts
│ │ └── events/
│ │ └── clientReady/
│ │ └── log.ts
│ └── app.ts
├── .env
├── .gitignore
├── commandkit.config.ts
├── package.json
└── tsconfig.json
The exact project structure may vary depending on the example you choose. Each example comes with its own configuration and dependencies tailored to its specific use case.
Entry point
The src/app.ts
file is the main entry point for your application.
This file default exports the discord.js client instance which
CommandKit loads at runtime.
- TypeScript
- JavaScript
import { Client } from 'discord.js';
const client = new Client({
intents: ['Guilds', 'GuildMessages', 'MessageContent'],
});
// Optional: Setting up the token manually
client.token = process.env.MY_BOT_TOKEN;
export default client;
import { Client } from 'discord.js';
const client = new Client({
intents: ['Guilds', 'GuildMessages', 'MessageContent'],
});
// Optional: Setting up the token manually
client.token = process.env.MY_BOT_TOKEN;
export default client;
Notice how there's no client.login()
in this file. This is because
CommandKit will automatically handle the login process for you when
the application starts.
Development version
If you would like to try the latest development builds, you can use
the @dev
tag like so:
- npm
- Yarn
- pnpm
- Bun
npm create commandkit@dev
yarn create commandkit@dev
pnpm create commandkit@dev
bunx create-commandkit@dev
The development version is likely to have bugs.
Getting Help
For more information about the CLI options, you can use the help flag:
- npm
- Yarn
- pnpm
- Bun
npm create commandkit@latest --help
yarn create commandkit --help
pnpm create commandkit --help
bunx create-commandkit --help
This will display all available options and usage examples.
Manual setup
Alternatively, if you would like to setup a new CommandKit project manually, you can follow this guide.