sync: auto-sync from GURU-5070 at 2026-06-15 09:41:53

Author: Mike Swanson
Machine: GURU-5070
Timestamp: 2026-06-15 09:41:53
This commit is contained in:
2026-06-15 09:42:15 -07:00
parent 206e6b6b67
commit 7084141b94
26 changed files with 537 additions and 13 deletions

View File

@@ -0,0 +1,80 @@
---
name: discord-dm
description: >
Send a Discord message to an org member's DMs or to a team channel via the
ClaudeTools bot. Use this whenever you need to hand a person something
copy-paste-friendly that the terminal would wrap or mangle — consent links,
long single-line commands, URLs, tokens-to-rotate notices — or to ping someone
directly. Prepopulated with every org member's user ID and the team channel IDs,
so you address people by name (mike/howard/rob/winter) not raw snowflakes.
Invoke on: "DM me/<person> in discord", "send <person> a discord message",
"message <person> on discord", "discord DM", "send that link to my discord",
"ping <person>". For one-line [SYNCRO]/[RMM] status alerts to the alert channels,
prefer post-bot-alert.sh; use this for direct/person-targeted delivery.
---
# 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.