← Back to PRs

#22965: fix(discord): pass accountId to ack reaction calls for named accounts

by arosstale open 2026-02-21 21:37 View on GitHub →
channel: discord size: XS experienced-contributor
## 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