Using CommandKit CLI
CommandKit CLI allows you to start, build, and manage your bot application. It also includes features such as HMR during development, anti-crash, etc. so you can be rest assured your bot won't crash and go offline during production.
To get a list of the available CLI commands, run the following command inside your project directory:
npx commandkit --help
The output should look something like this:
Usage: commandkit [options] [command]
Options:
-h, --help display help for command
Commands:
dev [options] Start your bot in development mode.
start [options] Start your bot in production mode after running the build command.
build [options] Build your project for production usage.
create [options] <name> Create new commands, events, or locale files
help [command] display help for command
CommandKit does not perform type checking on your code yet. You need to do that
yourself using tsc --noEmit
command or any other tool of your choice.
Available commands
Build
commandkit build
creates an optimized production build of your bot application. By default, commandkit emits the build to dist/
directory in your project. It supports typescript out of the box.
CommandKit also injects anti-crash script in your production build to prevent your bot from crashing due to cases like unhandled promise rejections. Although, it's recommended to handle these cases yourself. You can disable this behavior by setting antiCrash: false
in your commandkit.config.js
file.
Development
commandkit dev
starts your bot in development mode. It supports hot reloading out of the box to restart your bot only when it's needed. Changes made to commands/events files are automatically reloaded without restarting the bot. CommandKit automatically loads your environment variables from .env
file in your project directory, without you having to worry about it. It also supports typescript out of the box.
Production
commandkit start
starts your bot in production mode. You need to run commandkit build
before running this command. This command also loads the environment variables from .env
file in your project directory.
Create
commandkit create
creates new commands, events, or locale files. You can use this command to quickly scaffold new files in your project.