Getting Started

Prerequisites

Required

Optional

Installation

Using the Scaffold

This method is the fastest way to get started.

This is great for first timers or if you only plan to work on one bot at a time.

# Create a new bot
$ npm create chooks-bot <bot-name>

# Start your new bot
$ cd <bot-name>
$ npm run dev
# Create a new bot
$ yarn create chooks-bot <bot-name>

# Start your new bot
$ cd <bot-name>
$ yarn dev
# Create a new bot
$ pnpm create chooks-bot <bot-name>

# Start your new bot
$ cd <bot-name>
$ pnpm dev

Using the CLI Tool

This method is the fastest when developing multiple projects locally.

When deploying to an environment where you need to build from source (CI/CD pipelines), you need to add @chookscord/cli as a dev dependency in your project.

# Install CLI tool globally
$ npm i -g @chookscord/cli

# Create a new bot
$ chooks init <bot-name>

# Start your new bot
$ cd <bot-name>
$ chooks
# Install CLI tool globally
$ yarn global add @chookscord/cli

# Create a new bot
$ chooks init <bot-name>

# Start your new bot
$ cd <bot-name>
$ chooks
# Install CLI tool globally
$ pnpm add -g @chookscord/cli

# Create a new bot
$ chooks init <bot-name>

# Start your new bot
$ cd <bot-name>
$ chooks

Manual Installation

If you want to migrate an existing bot or don't want to use any of the methods above.

# Initialize your folder
$ npm init

# Install the framework and the CLI tool
$ npm i chooksie discord.js
$ npm i -D @chookscord/cli
# Initialize your folder
$ yarn init

# Install the framework and the CLI tool
$ yarn add chooksie discord.js
$ yarn add -D @chookscord/cli
# Initialize your folder
$ pnpm init

# Install the framework and the CLI tool
$ pnpm add chooksie discord.js
$ pnpm add -D @chookscord/cli

Expose CLI commands by adding the following scripts to your package.json

{
  "scripts": {
    "start": "node dist",
    "dev": "chooks",
    "build": "chooks build",
    "register": "chooks register"
  }
}

Place your credentials in an env file:

BOT_TOKEN=your-bot-token
DEV_SERVER=your-dev-server-id

Create a config file and use your credentials:

import { defineConfig } from 'chooksie'

export default defineConfig({
  token: process.env.BOT_TOKEN,
  devServer: process.env.DEV_SERVER,
  intents: [],
})
import { defineConfig } from 'chooksie'

export default defineConfig({
  token: process.env.BOT_TOKEN,
  devServer: process.env.DEV_SERVER,
  intents: [],
})
const { defineConfig } = require('chooksie')

module.exports = defineConfig({
  token: process.env.BOT_TOKEN,
  devServer: process.env.DEV_SERVER,
  intents: [],
})

For TypeScript Users

If you plan to use TypeScript, you must enable strict (or at the very least, noImplicitThis) for this context to work.

{
  "compilerOptions": {
    // recommended, noImplicitThis is required to have "this" types available.
    "strict": true,
    // just so you don't accidentally build your project using tsc
    "noEmit": true
  },
  "exclude": [
    "node_modules",
    "dist",
    ".chooks"
  ]
}

For PNPM Users

Since PNPM handles node_modules differentlyopen in new window, you need to enable shamefully-hoistopen in new window in your .npmrc file

shamefully-hoist = true

Once you did all of the above, you can run the dev script above and start creating files and the framework will detect and update your bot.