Skip to main content
Get your first CommandKit Discord bot running in just a few steps.

Prerequisites

Before you begin, ensure you have:
  • Node.js 24 or later installed
  • A Discord account and access to the Discord Developer Portal
  • Basic knowledge of TypeScript or JavaScript

Step 1: Create a Discord bot

1

Create a new application

  1. Go to the Discord Developer Portal
  2. Click New Application
  3. Give your application a name and click Create
2

Create a bot user

  1. Navigate to the Bot tab in the left sidebar
  2. Click Add Bot and confirm
  3. Under the bot’s username, click Reset Token to generate a new token
  4. Copy the token — you’ll need it soon (keep it secret!)
3

Enable intents

Scroll down to Privileged Gateway Intents and enable:
  • Server Members Intent (for member events)
  • Message Content Intent (if using prefix commands)
4

Invite the bot to your server

  1. Go to the OAuth2 → URL Generator tab
  2. Select these scopes:
    • bot
    • applications.commands
  3. Select bot permissions you need (at minimum: Send Messages, Use Slash Commands)
  4. Copy the generated URL and open it in your browser to invite the bot

Step 2: Create your CommandKit project

npm create commandkit
Follow the interactive prompts:
  1. Project name: Enter a name for your bot
  2. Template: Choose basic-ts (TypeScript) or basic-js (JavaScript)
  3. Install dependencies: Select Yes

Step 3: Configure your bot token

Create a .env file in your project root:
DISCORD_TOKEN=your_bot_token_here
DISCORD_CLIENT_ID=your_client_id_here
Replace your_bot_token_here with the token you copied earlier, and your_client_id_here with your application ID (found in the General Information tab).
Never commit your .env file to version control. Add it to .gitignore to keep your token safe.

Step 4: Start the development server

commandkit dev
Your bot will start, register commands with Discord, and begin listening for events. You’ll see output like:
✓ CommandKit is ready!
✓ Commands registered (3 commands)
✓ Logged in as YourBot#1234

Step 5: Test your bot

Your bot should now be online in your Discord server! Try these commands:
  • /ping — The bot responds with “Pong!” and its latency
  • Type !ping — Tests prefix command support (if you enabled Message Content intent)

Understanding the project structure

Your new CommandKit project has this structure:
my-bot/
├── src/
│   ├── app/
│   │   ├── commands/
│   │   │   └── ping.ts          # Your first command
│   │   └── events/
│   │       └── clientReady.ts   # Bot startup event
│   └── app.ts                   # Bot entry point
├── .env                         # Bot token (don't commit!)
├── commandkit.config.ts         # CommandKit configuration
└── package.json

The ping command

Open src/app/commands/ping.ts to see a basic command:
import type { CommandData, CommandOptions } from 'commandkit';

export const data: CommandData = {
  name: 'ping',
  description: 'Replies with Pong!',
};

export async function chatInput({ interaction, client }: CommandOptions) {
  const latency = Date.now() - interaction.createdTimestamp;
  const apiLatency = Math.round(client.ws.ping);

  await interaction.reply({
    content: `🏓 Pong! Latency: ${latency}ms | API: ${apiLatency}ms`,
  });
}
This shows CommandKit’s convention-based API:
  • Export data to define the slash command structure
  • Export chatInput to handle slash command interactions
  • No registration calls needed — CommandKit handles it automatically

What’s next?

Create commands

Learn how to build powerful slash commands

Handle events

Respond to Discord events like messages and member joins

Use JSX components

Build Discord UI with React-like JSX syntax

Add plugins

Extend your bot with AI, caching, and more
Having trouble? Check out the Installation guide for detailed setup instructions or join our Discord community for help.

Build docs developers (and LLMs) love