Skip to content

2026-89: fix(discord): capture replies to the bot without an explicit mention - #89

Merged
Ivory2024 merged 1 commit into
mainfrom
fm/firstmate-discord-reply-command-20261004
Oct 4, 2026
Merged

Ivory2024 merged 1 commit into
mainfrom
fm/firstmate-discord-reply-command-20261004

Conversation

@Ivory2024

Copy link
Copy Markdown
Owner

Intent

클로드
앱
— 오후 10:53
🎬 [이미 등록된 영화]
• 제목: )
• Notion Link: https://app.notion.com/p/3ef699a4fba6804f8848ea9d63ccfab5
박평식 — 오후 10:58
누락된 정보들 채워넣어

병렬로. 이런 식으로 답멘션 달면 명령 듣고 처리해줘야 하는데 반응이 없어 코드 수정해

What Changed

  • bin/fm-discord-poll.js: treat a message as an inbound command when it is a Discord reply to one of the bot's own messages (referenced_message.author.id === botId), even without an @mention; also tags forwarded messages with author_id.
  • bin/fm-discord-poll.js: DM channel discovery now runs unconditionally when FM_DISCORD_ALLOW_DMS is set, instead of being skipped when a guild channel allowlist is also configured, and dedupes against channels already in targetChannels.
  • docs/configuration.md: documents that replying to any bot message counts as a mention, and that DM polling runs alongside a configured channel allowlist.
  • tests/fm-discord-selfhosted.test.sh: adds coverage for the reply-without-mention and concurrent DM/allowlist polling behavior.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: Small, well-scoped fix: adds reply-to-bot detection and moves DM polling out of the allowlist-exclusive branch, matches stated intent, covered by new behavioral tests that exercise the real script and assert actual output files, no change to the existing authorization boundary.

Testing

Ran tests/fm-discord-selfhosted.test.sh which exercises the actual fm-discord-poll.sh/js binary against a fake Discord backend (fake node shim), checking real wake output and real state/x-inbox JSON files it writes. All scenarios relevant to this change passed: reply to bot's own message without mention is captured, reply to bot with mention still strips mention and is captured, reply to a non-bot member's message without mention is correctly ignored, and DM channels are still polled when a channel allowlist is configured. Worktree left clean (test uses its own tmp dirs).

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
reply_to_bot_without_mention_wakes_firstmate ✅ pass live test_reply_to_bot_message_without_mention in tests/fm-discord-selfhosted.test.sh: real fm-discord-poll.sh run produced wake 'x-mention discord-sh-1352000000000002001' and state/x-inbox/discord-sh-1352…
reply_to_bot_with_mention_still_captured_and_mention_stripped ✅ pass live test_reply_to_bot_message_with_mention: wake fired and inbox text had the <@id> mention stripped to 'fill it in'
reply_to_ordinary_member_without_mention_ignored ✅ pass live test_reply_to_member_without_mention_is_ignored: no wake output, no inbox file created for a reply to a non-bot author without explicit mention
dm_polled_even_with_channel_allowlist_configured ✅ pass live test_dm_reply_is_polled_with_configured_channel: DM channel id appears in fetch log and wake fired despite FM_DISCORD_CHANNEL_ID allowlist being set
Evidence: fm-discord-selfhosted.test.sh run
ok - a reply to the bot's own message without a mention is captured
ok - a reply to the bot's own message that also mentions the bot is captured
ok - a reply to a non-bot message without a mention is still ignored
ok - a DM command is polled and captured even when a channel allowlist is configured

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
reply_to_bot_without_mention_wakes_firstmate ✅ pass live test_reply_to_bot_message_without_mention in tests/fm-discord-selfhosted.test.sh: real fm-discord-poll.sh run produced wake 'x-mention discord-sh-1352000000000002001' and state/x-inbox/discord-sh-1352…
reply_to_bot_with_mention_still_captured_and_mention_stripped ✅ pass live test_reply_to_bot_message_with_mention: wake fired and inbox text had the <@id> mention stripped to 'fill it in'
reply_to_ordinary_member_without_mention_ignored ✅ pass live test_reply_to_member_without_mention_is_ignored: no wake output, no inbox file created for a reply to a non-bot author without explicit mention
dm_polled_even_with_channel_allowlist_configured ✅ pass live test_dm_reply_is_polled_with_configured_channel: DM channel id appears in fetch log and wake fired despite FM_DISCORD_CHANNEL_ID allowlist being set
  • bash tests/fm-discord-selfhosted.test.sh (full file, 11 tests including 4 new ones)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

A Discord reply to one of the bot's own messages was dropped whenever the
user did not also @mention the bot: the guild-channel poll filter required
isMentioned or a literal bot mention. The captain answers a bot post by
replying to it, and Discord adds no mention for that, so the command never
reached firstmate.

Treat a reply whose referenced message was authored by the bot as an inbound
mention, and discover the bot's DM channels even when FM_DISCORD_CHANNEL_ID
names a guild-channel allowlist. Carry the author id in the captured payload
so firstmate can authorise before acting on it.

Regression coverage: reply to a bot message with and without a mention, a
reply to a member still ignored, and a DM command captured under a configured
channel allowlist.
@Ivory2024 Ivory2024 changed the title fix(discord): capture replies to the bot without an explicit mention 2026-89: fix(discord): capture replies to the bot without an explicit mention Oct 4, 2026
@Ivory2024
Ivory2024 merged commit 4c73850 into main Oct 4, 2026
20 checks passed
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
* feat(discord): captain command channel for mention-free requests

Adds an explicit opt-in channel list where an authorized captain's plain message
is an inbound Firstmate request, without typing @FIRST Crew (which forces a
Korean/English IME round-trip on every call).

- bin/fm-discord-lib.sh: resolve FM_DISCORD_COMMAND_CHANNELS (one place); a
  command channel that is also excluded is dropped with an explicit diagnostic
  (exclusion wins).
- bin/fm-discord-poll.js: allow the mention-free path only when the polled
  channel is a command channel AND the author is authorized; bot messages and
  unauthorized authors are still ignored.
- bin/fm-discord-poll.sh: export the resolved command channels to the poll.
- docs/configuration.md: document the setting and how it differs from the
  polling allowlist.
- tests: authorized+command-channel plain -> captured; unauthorized -> ignored;
  ordinary channel plain -> ignored; duplicate poll -> one inbox record;
  command/exclusion conflict -> fail-safe diagnostic.

Preserves #89 (reply to bot), #93 (durable wake on capture), DM polling, and the
existing @mention fallback; all inputs still normalize to the same
discord-selfhosted x-inbox + durable-wake path.

* no-mistakes(document): Document Discord command channel configuration

* no-mistakes(lint): Replace ls/grep inbox count with glob loop
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
…89)

A Discord reply to one of the bot's own messages was dropped whenever the
user did not also @mention the bot: the guild-channel poll filter required
isMentioned or a literal bot mention. The captain answers a bot post by
replying to it, and Discord adds no mention for that, so the command never
reached firstmate.

Treat a reply whose referenced message was authored by the bot as an inbound
mention, and discover the bot's DM channels even when FM_DISCORD_CHANNEL_ID
names a guild-channel allowlist. Carry the author id in the captured payload
so firstmate can authorise before acting on it.

Regression coverage: reply to a bot message with and without a mention, a
reply to a member still ignored, and a DM command captured under a configured
channel allowlist.
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
* feat(discord): captain command channel for mention-free requests

Adds an explicit opt-in channel list where an authorized captain's plain message
is an inbound Firstmate request, without typing @FIRST Crew (which forces a
Korean/English IME round-trip on every call).

- bin/fm-discord-lib.sh: resolve FM_DISCORD_COMMAND_CHANNELS (one place); a
  command channel that is also excluded is dropped with an explicit diagnostic
  (exclusion wins).
- bin/fm-discord-poll.js: allow the mention-free path only when the polled
  channel is a command channel AND the author is authorized; bot messages and
  unauthorized authors are still ignored.
- bin/fm-discord-poll.sh: export the resolved command channels to the poll.
- docs/configuration.md: document the setting and how it differs from the
  polling allowlist.
- tests: authorized+command-channel plain -> captured; unauthorized -> ignored;
  ordinary channel plain -> ignored; duplicate poll -> one inbox record;
  command/exclusion conflict -> fail-safe diagnostic.

Preserves #89 (reply to bot), #93 (durable wake on capture), DM polling, and the
existing @mention fallback; all inputs still normalize to the same
discord-selfhosted x-inbox + durable-wake path.

* no-mistakes(document): Document Discord command channel configuration

* no-mistakes(lint): Replace ls/grep inbox count with glob loop
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
…89)

A Discord reply to one of the bot's own messages was dropped whenever the
user did not also @mention the bot: the guild-channel poll filter required
isMentioned or a literal bot mention. The captain answers a bot post by
replying to it, and Discord adds no mention for that, so the command never
reached firstmate.

Treat a reply whose referenced message was authored by the bot as an inbound
mention, and discover the bot's DM channels even when FM_DISCORD_CHANNEL_ID
names a guild-channel allowlist. Carry the author id in the captured payload
so firstmate can authorise before acting on it.

Regression coverage: reply to a bot message with and without a mention, a
reply to a member still ignored, and a DM command captured under a configured
channel allowlist.
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
* feat(discord): captain command channel for mention-free requests

Adds an explicit opt-in channel list where an authorized captain's plain message
is an inbound Firstmate request, without typing @FIRST Crew (which forces a
Korean/English IME round-trip on every call).

- bin/fm-discord-lib.sh: resolve FM_DISCORD_COMMAND_CHANNELS (one place); a
  command channel that is also excluded is dropped with an explicit diagnostic
  (exclusion wins).
- bin/fm-discord-poll.js: allow the mention-free path only when the polled
  channel is a command channel AND the author is authorized; bot messages and
  unauthorized authors are still ignored.
- bin/fm-discord-poll.sh: export the resolved command channels to the poll.
- docs/configuration.md: document the setting and how it differs from the
  polling allowlist.
- tests: authorized+command-channel plain -> captured; unauthorized -> ignored;
  ordinary channel plain -> ignored; duplicate poll -> one inbox record;
  command/exclusion conflict -> fail-safe diagnostic.

Preserves #89 (reply to bot), #93 (durable wake on capture), DM polling, and the
existing @mention fallback; all inputs still normalize to the same
discord-selfhosted x-inbox + durable-wake path.

* no-mistakes(document): Document Discord command channel configuration

* no-mistakes(lint): Replace ls/grep inbox count with glob loop
@Ivory2024
Ivory2024 deleted the fm/firstmate-discord-reply-command-20261004 branch October 10, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant