This fork is a TypeScript rewrite of imconnorngl's JavaScript bot template.
git
command line (Windows | Linux | MacOS) installed.node
Version 16.9.x or higher.pnpm
package manager installed.
- Go to the Discord Application Page.
- Create a New Application.
- Click Bot, Add Bot, then click Yes, do it.
- Visit
https://discord.com/oauth2/authorize?client_id=APP_ID&permissions=8&scope=bot%20applications.commands
, replacing APP_ID with the Application ID from the app page, to add the bot to your server. - Copy your bot's Token and keep it for later.
- Visit the same bot page where you got your token from.
- Under Privileged Gateway Intents, enable Presence Intent, Server Members Intent, and Message Content Intent.
- Click Save Changes at the bottom.
- Create a local folder to store your bot's source code in.
- Run
git clone https://github.com/Krumbit/bot-template.git .
in the folder directory. - Run
pnpm install
to install all required packages. - Rename the
.env.example
file to.env
and paste your bot's token after the equals sign. - Read the next section for information on how to run the bot.
These scripts use the
ts-node
CLI to run the TypeScript version of the bot, without transpiling to JavaScript. Use these only during development, as they are not as performant as the transpiled JavaScript version.
pnpm run dev
- Runs the bot once
pnpm run dev:watch
- Uses
nodemon
to automatically restart the bot after any file changes
- Uses
These scripts manage the transpiled JavaScript version of the bot, ideally, in a production environment. These are more optimized and less resource intensive than the
ts-node
counterpart.
pnpm run build
- Deletes the
dist/
directory (if exists) and transpiles the TypeScript project to JavaScript
- Deletes the
pnpm run start
- Starts the JavaScript version of the bot from the
dist/
directory - Requires
pnpm run build
to be ran previously
- Starts the JavaScript version of the bot from the
pnpm run build:start
- Combination of the previous two scripts - transpiles to JavaScript and starts the dist bot automatically
- When changing types or adding new items to the config JSON files, update the interfaces in the
src/utils/types
directory. You can use an interface generator to simplify the process. - When updating command categories, be sure to update the
Category
enum insrc/utils/structures/CommandHandler.ts
as well. The value of the enum is the display name in the command help embeds.