---
name: discord-dm
description: >
  Send a Discord message to an org member's DMs or a team channel via the ClaudeTools
  bot — for handing a person copy-paste-friendly content the terminal would mangle
  (consent links, long commands, URLs, tokens-to-rotate) or to ping someone. Addresses
  people by name (mike/howard/rob/winter), not raw snowflakes. Triggers: DM/message
  <person> in discord, discord DM, send that link to my discord, ping <person>.
---

# discord-dm — direct Discord messaging to the org

Thin wrapper over the Discord bot API. The engine is
`.claude/scripts/discord-dm.sh`; this doc is the usage contract.

## When to use

- **Wrapped command lines** — Mike's standing rule: any wrapped/long single-line
  output (M365 consent links, long CLI one-liners, URLs with query strings) gets
  **DM'd to him in Discord** so it's cleanly copy-pasteable, not mangled by terminal
  wrapping. Default target for that is `mike`.
- Pinging a specific teammate with something actionable.
- Posting to a team channel when you want to choose the channel explicitly
  (`#bot-alerts` / `#dev-alerts`).

For routine one-line `[SYNCRO]` / `[RMM]` status alerts, keep using
`post-bot-alert.sh` (it auto-routes by prefix). This skill is for **person-targeted
DMs** and deliberate channel posts.

## Usage

```bash
bash .claude/scripts/discord-dm.sh <recipient> "message text"
echo "message text" | bash .claude/scripts/discord-dm.sh <recipient>
bash .claude/scripts/discord-dm.sh list          # print known users + channels
```

`<recipient>`:

| Form | Effect |
|---|---|
| `mike` `howard` `rob` `winter` | opens/uses that user's DM channel |
| `#bot-alerts` / `bot` | posts to #bot-alerts (whole team) |
| `#dev-alerts` / `dev` | posts to #dev-alerts (Howard + Mike, private) |
| `chan:<id>` | posts to an arbitrary channel by ID |
| `<17-19 digit id>` | treated as a **user** DM |

## Prepopulated directory (from `.claude/users.json` + `post-bot-alert.sh`)

| Name | Discord user ID | | Channel | ID |
|---|---|---|---|---|
| mike | 264814939619721216 | | #bot-alerts | 624710699771232265 |
| howard | 624667664501178379 | | #dev-alerts | 1509998508198068484 |
| rob | 261978810713505792 | | | |
| winter | 624666486362996755 | | | |

Keep this table and the `USERS`/`CHANNELS` maps in the script in sync with
`.claude/users.json` when people are added/removed.

## Implementation notes / gotchas

- **Bot token** resolves from the SOPS vault
  (`projects/discord-bot/bot-token.sops.yaml` field `credentials.bot_token`),
  falling back to `projects/discord-bot/.env` `DISCORD_TOKEN`. Works from any
  machine, not just BEAST.
- **DMs** require opening the user's DM channel first
  (`POST /users/@me/channels {recipient_id}`) then posting to that channel id.
- **Multiline payloads:** always build JSON with `jq -nc --arg` and feed curl via
  `printf '%s' "$payload" | curl ... --data-binary @-`. Passing the JSON directly
  with `-d "$(...)"` mangled multiline content and returned Discord error
  `50109 invalid JSON body` (hit 2026-06-15 sending the CryoWeave consent link).
- **Not soft-fail:** unlike `post-bot-alert.sh`, a send failure exits non-zero —
  a requested DM is load-bearing, so surface the error.
- The bot must share a server with the user and the user must allow DMs from
  server members, or the DM-channel open / send can 403.
