> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Discord

A direct message with your own Discord bot, both ways. Taji's alerts reach your Discord DMs, and you talk to your agent from your phone by messaging the bot.

## Before you link

You need a Discord account, and a server you manage or a new empty one, so the bot can share a server with you. Taji reads the direct messages your bot receives and sends as it; it never reads a server's channels and never asks for your Discord password. Your vault must be open: it seals the bot token.

## Link

The form is `discord`. Start it from Discord's row under Channels on the Connections page. Its steps and the words it refuses with are the plugin's manifest, `taji-plugin.toml`; the last step is Taji's own. The sheet shows a code. From your own Discord account, send it in a direct message to your bot within ten minutes; `Show a new code` makes another. The account that sends the code is the owner. Once linked, the row shows when Taji last sent to you.

## Use

1. **Get alerts.** Every alert Taji raises arrives as a message from your bot in your DMs. Your agent sends nothing for it.
2. **Talk to your agent.** Message your bot from the owner account. The Taji window can be closed. The reply is your agent's last message: the figure first, then one or two short sentences.
3. **Ask for a chart.** Say "show me" or "chart". The reply carries the chart as an attached picture, `taji.png`. Without that, you get text and an offer of the picture.
4. **Answer a permission card.** When your agent needs a permission, the message carries buttons such as Yes, Always and No. Press one; Taji takes the buttons off the message. If Discord does not take Taji's answer, the buttons stay; your first press still counts, and pressing again answers `No such request.`
5. **Start a new thread or switch agent.** Send `taji new` to start a new thread, `taji agent` to list your agents and `taji agent <id>` to switch. Taji answers these itself; the agent never sees them.

The bot is the one you created and named; it hears only your direct messages to it, and a message in a server channel is ignored.

**Is it your bot?** Taji has no Discord bot of its own: a bot that messages you is one you set up. A genuine message never asks you to open a link to sign in or verify, and never asks for your bot token, a pairing code, a key or a password. Approvals happen only in the Taji window.

An order's approval cannot come from your phone. On an account with approvals on, the order waits in the Taji window and your agent says so. What your agent can and cannot do is in [Connect your agent](https://docs.taji.is/guide/agent.md).

## Unlink

Unlink Discord from its row under Channels on the Connections page (or `POST /verb/channels/unlink` with `{"channel": "discord"}`) while your vault is open. Taji stops the Gateway connection, deletes the sealed bot token from the vault, clears pending permission cards, and removes the link and owner pairing from its state.

Taji does not revoke the token at Discord. In the [Discord Developer Portal](https://discord.com/developers/applications), open your application and reset the bot token on the **Bot** page (or delete the application), and remove the bot from your server if you no longer want it there.

## If it fails

| Symptom | Cause | Fix |
|---|---|---|
| The sheet refuses with `invalid_key` | Discord did not accept the bot token | Reset the token on the Bot page of your application and paste the new one |
| The sheet or a send fails with `no_dm` | Discord cannot deliver the bot's DM, because you share no server with the bot | Add the bot to a server you are in, then try again |
| Discord's row says Discord's daily session starts are spent | Taji started more Discord sessions today than Discord allows | Nothing: Taji connects again when Discord's count resets, in the minutes the row gives; where Discord named no reset, Taji asks it again every few seconds |
| Discord's row says Discord asked Taji to slow down | Discord rate-limited your bot and named how long to wait | Nothing: Taji sends nothing until the wait has passed, and a message due meanwhile fails with that error |
| Discord's row reads Vault locked | The vault is closed after a restart | Open the vault in the Taji window; nothing sends until you do |

## References

- [How the Discord plugin works](https://docs.taji.is/catalog/discord/architecture.md)
- [Connect your agent](https://docs.taji.is/guide/agent.md)
- [How your agent answers a phone turn](https://docs.taji.is/skill/references/channels.md)
- [Discord Gateway](https://docs.discord.com/developers/events/gateway)
- [Create a Discord bot](https://docs.discord.com/developers/quick-start/getting-started)
- `plugins/discord/taji-plugin.toml`, `plugins/discord/src/lib.rs` (sending), `plugins/discord/src/gateway.rs` (receiving)
