# Discord The `discord` extension connects a session to a bot and delivers permitted messages and reactions as session events. [`extension.gleam`](../src/albedo/harness/extensions/discord/extension.gleam) registers its storage, manager, service, and Python binding. See [webhooks](webhooks.md) for signed HTTP event delivery. ## Setup The [Discord service](../src/albedo/harness/extensions/discord/service.gleam) creates bots with a session, name, token, and owner ID. Its routes manage bots, channel delivery, and DM access. The [terminal client](tui.md) and [web client](web.md) provide settings pages. The extension's startup starts the manager, but successful startup does not mean a bot has connected. ## Channels and delivery [`ingest.gleam`](../src/albedo/harness/extensions/discord/ingest.gleam) delivers messages from configured channels according to their `tool` or `turn` setting. The settings choose delivery after a tool call or after a turn. A mentions-only channel filters messages that do not mention the bot. The owner and allowed users can send DMs. Other DM senders create requests rather than inbox letters. Reactions use the same delivery choices and additional filtering. Discord messages and reactions are external conversation. They are not instructions from the user or blanket approval for an action. ## Kernel binding [`discord.py`](../priv/python/albedo_plugins/discord.py) exposes `send`, `dm`, `history`, `react`, `channels`, and `status`. Channels can be addressed by handle or name. Messages use numbers. `send` and `dm` require text or files. The binding accepts at most ten files, each at most 10 MiB, and checks that each path is a file. Host failures raise `DiscordError`. ## Bot process [`manager.gleam`](../src/albedo/harness/extensions/discord/manager.gleam) owns bot processes and reconciles their state. [`albedo_discord.py`](../priv/python/albedo_discord.py) implements the helper process. Ordinary requests have a 15-second timeout. Catch-up uses 60 seconds. The [startup callback](../src/albedo/harness/extensions/discord/extension.gleam) registers manager shutdown with the store. A startup failure is distinct from a bot's connection state. ## Related pages - [All topics](README.md) - [Change guidance](contributing.md) - [Webhooks](webhooks.md) - [Session attachment](sessions.md)