Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Discord Setup

Discord is Ariel's first chat platform. The backend, ariel-discord, is built on twilight (ADR 0010) and compiled into arield by the default discord feature.

arield starts the backend as soon as ARIEL_DISCORD_TOKEN_FILE, ARIEL_DISCORD_GUILD_ID and ARIEL_DISCORD_APPLICATION_ID are all set (Configuration): it registers the /ariel commands, reads interactions over the Gateway, and posts notifications. The smoke test below exercises the backend on its own against a real guild, without a prosperod or gonzalod.

What the backend does

  • Commands. Registers one guild slash command, /ariel, with a subcommand for each command the core declares — link, status, spawn, kill, respawn, channel, configure and invite (Chat Commands). Guild commands update immediately.
  • Receiving. Connects to the Gateway with no privileged intents, since interactions arrive without them, and turns /ariel interactions into commands for the core. Other interactions are ignored.
  • Replying. Answers within Discord's 3-second interaction deadline. If the core has not replied after 2 seconds, the backend defers on its behalf, then edits the deferred response or sends a follow-up. Private replies are ephemeral.
  • Posting. Sends messages as embeds (title, description, inline fields, link) colored by severity, edits them in place, opens direct messages, and starts threads from a message.
  • Limits. Advertises Discord's embed limits (256-character title, 4096-character description, 25 fields of 1024 characters, 6000 characters in total) and a send budget of a burst of 5 and 3600 per hour. twilight's REST client handles Discord's own rate-limit buckets and retries.
  • Not supported yet: buttons and reading thread replies.

Smoke test

The smoke test is kept in the repository at docs/discord-smoke-test.md and included here.

The Discord backend's contract tests run against a stub of Discord's REST API, and never open a real Gateway connection (ADR 0010). This manual test checks the parts they cannot: a real bot token, slash command registration, posting, the Gateway connection, and answering an interaction inside Discord's three-second deadline.

One-time setup

  1. In the Discord developer portal, create an application and add a bot to it.
  2. Copy:
    • the bot token (Bot → Reset Token);
    • the application ID (General Information).
  3. Create a test guild, or use one you administer, and enable Developer Mode in Discord's settings so you can copy IDs.
  4. Invite the bot with the bot and applications.commands scopes and these permissions: View Channels, Send Messages, Embed Links, Create Public Threads, Send Messages in Threads. The portal's OAuth2 URL generator builds the link.
  5. Copy the guild ID and the ID of a channel the bot can post in.

No privileged Gateway intents are needed: interactions arrive without them.

Run

export DISCORD_TOKEN='...'
export DISCORD_APPLICATION_ID='...'
export DISCORD_GUILD_ID='...'
export DISCORD_CHANNEL_ID='...'
cargo run -p ariel-discord --example smoke

Keep the token out of shell history and never commit it.

Expected results

StepPass if
RegistrationThe example prints registered /ariel status in guild …, and /ariel status appears in the guild's slash command list within a few seconds (guild commands update immediately).
Postingariel smoke: connected appears in the channel as an embed, and the example prints posted message ….
GatewayThe example prints listening; … with no Gateway errors logged.
InteractionRunning /ariel status shows ariel smoke: ok in the channel, and the example prints received /ariel status … then replied: Ok(…). Discord never shows "The application did not respond".

Stop the example with Ctrl-C.

Recording a run

Note the date, the ariel commit, and any step that failed, in the pull request or ticket that needed the smoke test.