# Deployed commands

Your bot sends its commands to Discord every time it starts. Covers the request that replaces a whole scope, the last global command that stays live, removing guild commands, and the flags.

Discord keeps its own copy of your commands. Your bot sends that copy every time it starts, so your command folder decides what people see.

Nothing in your build or your deploy pipeline calls Discord.

## Each request replaces the whole scope

Your bot sends one request per scope. One carries every global command. Each server with a guild command gets its own.

Discord replaces the whole scope with what arrives. If you delete a command file, that command is gone the next time your bot starts. A rename does the same to the old name.

## Deleting your last global command leaves it live

Your bot skips the request when a scope has nothing left in it.

That leaves one gap. If you remove your *last* global command, your bot sends nothing, so the copy Discord already has stays. The same happens to the last guild command in a server.

Adding another global command fixes the global scope on the next start. Guild commands need `seedcord commands`.

## Removing guild commands

`seedcord commands` deletes deployed guild commands. It reads `DISCORD_BOT_TOKEN` from your `.env`, fetches what Discord currently has, and prints the list before it deletes anything.

```sh
pnpm exec seedcord commands
```

Without flags, on a real terminal, it asks which servers to look at and what to remove. Anywhere without a terminal, or with `CI` set, it prints what it would need and exits.

Flags do the same work without the prompts. The common case is a command you moved from one server to global, which Discord then shows twice in the picker.

```sh
pnpm exec seedcord commands --clean --guild 613425648685547541 --apply
```

`--clean` finds every guild command whose name also exists globally. Drop `--apply` to print them without removing anything.

To empty a server completely, `--purge` deletes every command in the servers you name.

```sh
pnpm exec seedcord commands --purge --guild 613425648685547541 --apply
```

For CI, `--all-guilds` covers every server your bot is in. `--yes` is required there, since `--apply` asks you to confirm the count and throws `CliCleanApplyNeedsYes` when it can't find a terminal to ask on.

```sh
pnpm exec seedcord commands --clean --all-guilds --apply --yes
```

## The flags

{/* prettier-ignore-start */}

| flag               | what it does                                        |
| ------------------ | --------------------------------------------------- |
| `--clean`          | Find guild commands that duplicate a global command |
| `--guild <ids...>` | The servers to look at, one id or several           |
| `--all-guilds`     | Every server your bot is in                         |
| `--purge`          | Delete every command in the named servers           |
| `--apply`          | Delete what was found                               |
| `--yes`            | Skip the prompts, for CI                            |

{/* prettier-ignore-end */}

> **Warning**
>
> `--purge` needs named servers. Passing `--all-guilds` alongside it throws, since that pair would delete every guild command your bot has. Passing neither `--guild` nor `--all-guilds` throws too, since `--purge` then has nothing to aim at.

> **Note**
>
> `seedcord commands` only ever deletes guild commands. To remove a global one, delete its file and let a later start replace the scope.
