#22965: fix(discord): pass accountId to ack reaction calls for named accounts
channel: discord
size: XS
experienced-contributor
Cluster:
Signal and Discord Fixes
## What broke
With named Discord accounts (`channels.discord.accounts.<name>.token`, no root `channels.discord.token`), ack reactions silently failed on every message.
The ack reaction adapter in `processDiscordMessage` called `reactMessageDiscord` and `removeReactionDiscord` **without `accountId`**:
```ts
setReaction: async (emoji) => {
await reactMessageDiscord(messageChannelId, message.id, emoji, {
rest: client.rest as never,
// ← accountId missing
});
},
```
This caused `createDiscordRestClient` to fall back to `accountId = "default"`. With named-only accounts there is no default token, so the token resolver threw `"Discord bot token missing for account 'default'"`. The error was caught inside `applyEmoji`'s try/catch and forwarded to `onError`, which logs via `logVerbose` — **invisible at debug level**.
## Fix
Forward the `accountId` already destructured from `ctx` at the top of `processDiscordMessage` to both `reactMessageDiscord` and `removeReactionDiscord`.
## Tests
- Updated two existing assertions that expected `{ rest: {} }` to now correctly expect `{ rest: {}, accountId: "default" }`
- Added new test: `"passes accountId to reactMessageDiscord for named accounts"` — verifies that `accountId: "coach_claw"` propagates to the reaction call
Fixes #22938
---
> [AI-assisted]
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes silent ack reaction failures for Discord named accounts by forwarding `accountId` to reaction API calls.
**Key changes:**
- `src/discord/monitor/message-handler.process.ts:136,142` - Added `accountId` parameter to `reactMessageDiscord` and `removeReactionDiscord` calls
- Updated two existing test assertions to expect `accountId: "default"` in the reaction calls
- Added regression test for named account scenario (`accountId: "coach_claw"`)
**How it works:**
The `accountId` was already destructured from `ctx` at the top of `processDiscordMessage` (line 62) but wasn't being passed to the `StatusReactionAdapter` callbacks. Without it, `createDiscordRestClient` in `src/discord/client.ts:34-43` falls back to `accountId = "default"` via `normalizeAccountId()`, which then fails token resolution for setups with only named accounts (no root `channels.discord.token`). The fix ensures the correct account's token is used for ack reactions.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The fix is surgical and well-tested: it only adds a missing parameter that was already available in scope, the change is covered by updated existing tests plus a new regression test, the CHANGELOG entry is thorough, and the PR description clearly documents the root cause and fix
- No files require special attention
<sub>Last reviewed commit: 8082ecb</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22973: fix(discord): pass accountId to ack reaction handlers
by miloudbelarebia · 2026-02-21
90.8%
#19615: fix(discord): include default account when sub-accounts are configured
by prue-starfield · 2026-02-18
79.4%
#17316: fix: ack reaction not removed when block streaming is enabled (Tele...
by czmathew · 2026-02-15
76.7%
#19917: feat(discord): allow disabling intermediate status reactions
by Gitjay11 · 2026-02-18
75.6%
#17395: fix(discord): default dm config for sub-accounts to prevent silent ...
by deggertsen · 2026-02-15
75.5%
#22557: fix(discord): coerce exec approval approver IDs to string to preven...
by zwffff · 2026-02-21
74.2%
#20967: fix(discord): report connected state so health-monitor can restart ...
by who96 · 2026-02-19
72.9%
#20009: fix(discord): immediately defer interactions to prevent timeouts
by Gitjay11 · 2026-02-18
72.9%
#23728: fix(telegram): clear done reaction when removeAckAfterReply is true
by kevinWangSheng · 2026-02-22
72.8%
#14977: fix(telegram): remove ack reaction after block-streamed replies
by Diaspar4u · 2026-02-12
72.3%