# Tooling

Point the seedcord CLI at your bot with seedcord.config.ts, and pick the command that runs, builds, or deploys it.

A seedcord project has two config files, because two different programs read them. `seedcord dev`, `codegen`, `build`, and `commands deploy` have to import your bot before it runs, so they need its path from somewhere other than the bot itself. `seedcord.config.ts` holds that path for the CLI. The `new Seedcord({ ... })` call in `src/bot.ts` builds a [`Seedcord`](https://seedcord.org/docs/packages/gateway/latest/classes/seedcord) bot and configures it while it runs.

The CLI looks for `seedcord.config.ts` or `seedcord.config.mts` in the directory you run it from.

```ts title="seedcord.config.ts"
import { defineConfig } from 'seedcord';

export default defineConfig({
    root: './src',
    instance: './bot.ts',
    build: { start: './index.ts' }
});
```

Only `instance` is required. `build.start` is optional. Without it, the build's `index.mjs` default-exports the bot for your own node server to start. An edge bot, which [runs on Cloudflare Workers](https://preview.seedcord.org/guide/build/workers/), leaves it out too. [Your first bot](https://preview.seedcord.org/guide/first-bot/#where-your-folders-resolve) explains how `root`, `instance`, and `build.start` fit together.

Every other key is optional: `root`, `files`, `vitePlugins`, `tunnel`, `hmr`, `idleAnimation`, the rest of `build`, and `port` on an edge bot. [The config reference](https://preview.seedcord.org/guide/build/config/) lists each one with its default. `vitePlugins` takes a function that returns [Vite plugins](https://preview.seedcord.org/guide/build/vite-plugins/), like `() => [yaml()]`.

## The commands

{/* prettier-ignore-start */}

| command                                                                     | what it does                                                                                                                  |
| --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [`seedcord dev`](https://preview.seedcord.org/guide/tooling/dev/)           | runs your bot, reloads a changed file in place, and prints its logs in a terminal you can filter. An edge bot runs in workerd |
| [`seedcord codegen`](https://preview.seedcord.org/guide/tooling/codegen/)   | imports your bot and command files, then writes `seedcord-gen.d.ts` into `root`                                               |
| [`seedcord build`](https://preview.seedcord.org/guide/build/)               | type checks your bot and bundles it for a server, a Cloudflare Worker, or another program to import                           |
| [`seedcord commands`](https://preview.seedcord.org/guide/tooling/commands/) | deploys your commands to Discord, lists what Discord holds, and deletes the ones you no longer want                           |

{/* prettier-ignore-end */}

A project from `create-seedcord` wraps these as scripts, along with `check`, `commands:deploy`, and the `deploy` and `types` scripts of an edge bot. [Your first bot](https://preview.seedcord.org/guide/first-bot/#scripts) lists every one.

## Your bot's config

`src/bot.ts` holds the second config, the one your bot reads. Every key gets taught on the page that needs it, inside a real `new Seedcord({ ... })` sample. The last column links to that page.

`bot`, `subscribers`, `bot.interactions`, and `bot.commands` are required. A gateway bot also has to set `bot.events` and `bot.clientOptions`. Every other key is optional.

{/* prettier-ignore-start */}

| key                 | what it sets                                                                                                                 | where it's taught                                                                                                                            |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `bot.interactions`  | the folder seedcord scans for handlers, plus middleware and ignored ids                                                      | [Components](https://preview.seedcord.org/guide/components/)                                                                                 |
| `bot.commands`      | the folder seedcord scans for commands, and `guilds`, the test servers that bare `@RegisterCommand()` commands deploy to     | [Commands](https://preview.seedcord.org/guide/commands/), [Test servers](https://preview.seedcord.org/guide/commands/deployed/#test-servers) |
| `bot.emojis`        | the emoji names [`Emojis`](https://seedcord.org/docs/packages/gateway/latest/variables/emojis) resolves at startup           | [Components](https://preview.seedcord.org/guide/components/)                                                                                 |
| `bot.events`        | the folder seedcord scans for event handlers. Gateway only                                                                   | [Events](https://preview.seedcord.org/guide/events/)                                                                                         |
| `bot.clientOptions` | passed straight to the discord.js `Client`. Gateway only                                                                     | [Your first bot](https://preview.seedcord.org/guide/first-bot/)                                                                              |
| `subscribers`       | the folder seedcord scans for bus subscribers                                                                                | [The bus](https://preview.seedcord.org/guide/events/bus/)                                                                                    |
| `errors`            | how a fault renders, what gets logged, which api error codes get ignored                                                     | [Tuning error behavior](https://preview.seedcord.org/guide/replying/error-behavior/)                                                         |
| `notifications`     | the contact name in the generic unknown-error message                                                                        | [Faults](https://preview.seedcord.org/guide/replying/faults/)                                                                                |
| `botColor`          | the accent on every [`BuilderComponent`](https://seedcord.org/docs/packages/core/latest/classes/builder-component) you build | [Components](https://preview.seedcord.org/guide/components/)                                                                                 |
| `ownerIds`          | the ids [`OwnerOnly`](https://seedcord.org/docs/packages/core/latest/functions/owner-only) treats as owners                  | [Gates](https://preview.seedcord.org/guide/checks/gates/)                                                                                    |
| `store`             | a durable store for framework state. The default keeps it in memory and loses it on restart                                  | [The rate limiter](https://preview.seedcord.org/guide/checks/rate-limiter/)                                                                  |
| `logger`            | the level, the sinks, and the per-channel overrides                                                                          | [Configuring the logger](https://preview.seedcord.org/guide/tooling/logger-config/)                                                          |
| `lifecycle`         | `shutdownDeadline`, how long shutdown may take                                                                               | [The lifecycle](https://preview.seedcord.org/guide/plugins/lifecycle/)                                                                       |

{/* prettier-ignore-end */}

> **Gateway and http differ**
>
> Each transport package declares its own `Seedcord` and its own config type, and a few keys only exist on one of them.
>
> * Both http configs take `bot.restOptions`. Only a node http server takes `port`, which defaults to 3000, and `port: false` lets [your own server](https://preview.seedcord.org/guide/build/embed/) host the bot. TypeScript rejects `port`, `lifecycle`, and `healthCheck` on an edge bot.
> * `healthCheck` takes different options on gateway and on a node http server. [The health server](https://preview.seedcord.org/guide/build/server/#the-health-server) covers both.
> * [`Emojis`](https://seedcord.org/docs/packages/gateway/latest/variables/emojis) on gateway holds a subclass of [`ResolvedEmoji`](https://seedcord.org/docs/packages/core/latest/classes/resolved-emoji) tied to the discord.js `GuildEmoji` or `ApplicationEmoji`. [`Emojis`](https://seedcord.org/docs/packages/http/latest/variables/emojis) on http holds a plain `ResolvedEmoji`.

The reference site has the full type of every one of these, down to each nested field.

Next, [the dev terminal](https://preview.seedcord.org/guide/tooling/dev/) runs your bot while you edit it. An http bot also needs [a tunnel](https://preview.seedcord.org/guide/tooling/tunnel/) before Discord can reach it on your machine.
