> ## Documentation Index
> Fetch the complete documentation index at: https://chatcli.edilsonfreitas.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Discord

> Talk to ChatCLI from Discord: a bot on the Discord Gateway WebSocket, no public URL needed, with voice and image messages in and long replies split across messages.

The Discord adapter connects out to the **Discord Gateway** over a WebSocket, so like Telegram it needs no public URL and opens no port. The bot reads every message in the channels and DMs it can see, which makes Discord's own channel permissions the way to decide who can use it.

| | Discord |
| - | - |
| Transport | Discord Gateway WebSocket v10; no port is opened |
| Who can talk to the bot | Anyone who can post where the bot can read; there is no user allow-list |
| Voice notes in | Yes, an audio attachment |
| Voice replies | No (text only) |
| Images in | Yes |
| Images out | Yes |
| "Working on it" signal | One short text notice if the reply takes more than about 2 seconds |

## Set it up

<Steps>
  <Step title="Create the application and bot">
    In the Discord Developer Portal, create an application, add a **Bot** and copy its token.
  </Step>

  <Step title="Turn on the Message Content intent">
    Under **Bot → Privileged Gateway Intents**, enable **Message Content Intent**. The gateway requests it to read what people write; without it Discord refuses the connection.
  </Step>

  <Step title="Invite the bot">
    Use the OAuth2 URL generator with the `bot` scope and the permissions to read messages, send messages and attach files, then open the URL and add the bot to your server. Direct messages to the bot work as well.
  </Step>

  <Step title="Configure ChatCLI and start">
    ```bash theme={"system"}
    export CHATCLI_DISCORD_BOT_TOKEN="..."
    ```

    ```text theme={"system"}
    /gateway start
    /gateway status     # discord should be listed
    ```
  </Step>
</Steps>

## Environment variables

| Variable | Required | Default | What it does |
| - | - | - | - |
| `CHATCLI_DISCORD_BOT_TOKEN` | yes | — | The bot token. The adapter starts only when it is set. |
| `CHATCLI_DISCORD_HOME_CHANNEL` | no | — | Default channel ID for [proactive messages](/gateway/proactive-messaging) sent with `@send discord`. |

## Who can reach the bot

<Warning>
  The bot answers **every** message from a person in every server channel and DM it can read; it does not wait for a mention and has no allow-list. Each message runs the agent with its tools and shell, so give the bot access only to a private channel, or to the people who should use it.
</Warning>

Messages written by bots, including this one, are ignored.

## Messages

* **Text**: the message content. A server channel is one conversation shared by everyone in it; a DM is its own.
* **Voice**: the first audio attachment is downloaded and transcribed before the agent runs.
* **Images**: the first image attachment reaches the model.
* **Image replies** are uploaded as a file on the reply; on failure the text is sent alone.
* **Long replies** go out as several messages in order, split at line breaks or spaces, because Discord accepts at most 2000 characters per message.
* Replies are posted in the channel, not as a reply to the original message.

## Limits

* A reply is cut at **3500 characters** before it is split, so it arrives as at most two messages.
* After a disconnect the bot reconnects with a new session; messages sent during the gap are not delivered to it.

## Troubleshooting

<AccordionGroup>
  <Accordion title="The bot is online but never answers">
    Enable the **Message Content Intent** in the Developer Portal. Without it the gateway cannot read message text and the connection is refused; `~/.chatcli/gateway.log` shows the error.
  </Accordion>

  <Accordion title="The bot answers in channels it should not">
    Remove its permission to read those channels in the server settings. The bot has no allow-list of its own.
  </Accordion>
</AccordionGroup>

## See also

<CardGroup cols={2}>
  <Card title="Chat gateway" icon="comments" href="/gateway/chat-gateway">
    How messages run, voice, images, continuity and the other channels.
  </Card>

  <Card title="Security" icon="shield-halved" href="/security/overview">
    Harden what the agent may do when it runs unattended.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.