Skip to content

fix(src): reliably post and auto-pin the help walkthrough - #64

Open
phorcys420 wants to merge 1 commit into
mainfrom
phorcys/walkthrough-reliable-send-and-pin
Open

fix(src): reliably post and auto-pin the help walkthrough#64
phorcys420 wants to merge 1 commit into
mainfrom
phorcys/walkthrough-reliable-send-and-pin

Conversation

@phorcys420

Copy link
Copy Markdown
Member

What

Fixes two issues with the #help forum walkthrough:

  1. Sometimes never posts on new threads. A forum post's ThreadCreate fires
    before the OP's starter message lands, and Discord rejects bot messages until
    it does (DiscordAPIError[40058]). The old channel.send had no error
    handling, so the rejection was swallowed and the walkthrough silently went
    missing (worse when the starter post has a large upload).
  2. Never auto-pins. Pinning only happened after all three fields were
    answered, so the auto-sent message was left unpinned.

Changes

  • sendWalkthrough() retries the send up to 5x (~2s apart, ~10s window),
    catching only 40058 and rethrowing anything else.
  • pinQuietly() pins the message and swallows + logs failures.
  • Walkthrough is pinned the moment it is posted, on both the auto-send and the
    /walkthrough fallback paths. The pin-on-completion block is removed.
  • ThreadCreate now gates on newlyCreated so re-cached threads on gateway
    reconnect don't double-post.

Verification

bunx tsc --noEmit, bun format, and bun lint all clean. No test suite in
this repo.

Implementation plan

Context / root cause

  • Auto-send is wired to ThreadCreate in src/events/walkthrough.ts, which
    calls doWalkthrough -> channel.send(...) with no error handling.
  • Discord fires ThreadCreate for a forum post before the OP's starter message
    lands. Sending too early is rejected with DiscordAPIError[40058]. It is
    intermittent because the delay grows when the starter post has a large upload.
    The rejection is swallowed as an unhandled rejection, so the walkthrough
    silently never appears.
  • Pinning only happened in handleSelection once all three fields were answered
    (values.length === steps.length).

Changes

src/events/walkthrough.ts

  • Accept the second ThreadCreate arg and bail when not newly created.

src/commands/util/walkthrough.ts

  • sleep, STARTER_NOT_READY = 40058, sendWalkthrough (retry with backoff),
    and pinQuietly helpers.
  • Auto path: try/catch, send via retry, pin, log on give-up.
  • Interaction path: pin the reply via fetchReply().
  • Remove the pin-on-completion block in handleSelection.

No config, schema, command-registration, or dependency changes.

Out of scope

  • Reworking the auto-send to trigger off the OP's first MessageCreate (cleaner
    but larger; retry covers the reported bug).
  • Selector UI, log guides, or Linear bridge changes.

Generated by Coder Agents on behalf of @phorcys420.

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