> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# discord

> Discord REST API client speaking the OpenClaw Discord action vocabulary.

Discord REST API client speaking the OpenClaw Discord action vocabulary. Install it on the workspace and the whole tree is
discoverable with `discord --help`.

## Install

```python theme={null}
from mirage import Workspace
from mirage.commands.cli.builtin.discord import DISCORD
from mirage.core.discord.config import DiscordConfig
from mirage.resource.discord import DiscordResource

config = DiscordConfig(token="bot-token")
ws = Workspace({"/discord": DiscordResource(config)})
ws.register_cli("discord", DISCORD, config.model_dump())
```

Two installs under different names are two accounts. In YAML, the same
install rides the `clis:` section; see the [CLI overview](/python/cli/index).

## Verbs

The verbs follow the OpenClaw Discord action vocabulary (bare verbs:
`send`, `read`, `edit`, `delete`, `react`, `search`, `thread-create`,
`poll`); `members` and `server-info` are mirage extensions. IDs are
Discord snowflakes, discoverable from the mounted tree
(`<name>__<id>` path segments).

### Messages

```bash theme={null}
discord send --channel 1256522563555819574 --text "Hello from MIRAGE"
discord send --channel 1256522563555819574 --text "A reply" --reply-to 1489887688978075769
discord read --channel 1256522563555819574 --limit 20
discord edit --channel 1256522563555819574 --message 1489887688978075769 --text "Edited"
discord delete --channel 1256522563555819574 --message 1489887688978075769
```

| Verb     | Flags                           | Writes |
| -------- | ------------------------------- | ------ |
| `send`   | `--channel --text [--reply-to]` | yes    |
| `read`   | `--channel [--limit]`           | no     |
| `edit`   | `--channel --message --text`    | yes    |
| `delete` | `--channel --message`           | yes    |

`edit` only works on messages the bot authored.

### Reactions, threads, polls

```bash theme={null}
discord react --channel 1256522563555819574 --message 1489887688978075769 --emoji "👍"
discord thread-create --channel 1256522563555819574 --message 1489887688978075769 --name "Budget talk"
discord poll --channel 1256522563555819574 --question "Lunch?" --answer Pizza --answer Sushi --duration 24
```

| Verb            | Flags                                                           | Writes |
| --------------- | --------------------------------------------------------------- | ------ |
| `react`         | `--channel --message --emoji`                                   | yes    |
| `thread-create` | `--channel --name [--message]`                                  | yes    |
| `poll`          | `--channel --question --answer... [--duration] [--multiselect]` | yes    |

`--answer` repeats, one per poll option.

### Guild metadata and search

```bash theme={null}
discord server-info --guild 1256522563555819574
discord members --guild 1256522563555819574 --query "alice"
discord search --guild 1256522563555819574 --query "deploy" --channel 1256522563555819574
```

| Verb          | Flags                         | Writes |
| ------------- | ----------------------------- | ------ |
| `server-info` | `--guild`                     | no     |
| `members`     | `--guild [--query]`           | no     |
| `search`      | `--guild --query [--channel]` | no     |
