fix(src): reliably post and auto-pin the help walkthrough - #64
Open
phorcys420 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes two issues with the #help forum walkthrough:
ThreadCreatefiresbefore the OP's starter message lands, and Discord rejects bot messages until
it does (
DiscordAPIError[40058]). The oldchannel.sendhad no errorhandling, so the rejection was swallowed and the walkthrough silently went
missing (worse when the starter post has a large upload).
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./walkthroughfallback paths. The pin-on-completion block is removed.ThreadCreatenow gates onnewlyCreatedso re-cached threads on gatewayreconnect don't double-post.
Verification
bunx tsc --noEmit,bun format, andbun lintall clean. No test suite inthis repo.
Implementation plan
Context / root cause
ThreadCreateinsrc/events/walkthrough.ts, whichcalls
doWalkthrough->channel.send(...)with no error handling.ThreadCreatefor a forum post before the OP's starter messagelands. Sending too early is rejected with
DiscordAPIError[40058]. It isintermittent 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.
handleSelectiononce all three fields were answered(
values.length === steps.length).Changes
src/events/walkthrough.tsThreadCreatearg and bail when not newly created.src/commands/util/walkthrough.tssleep,STARTER_NOT_READY = 40058,sendWalkthrough(retry with backoff),and
pinQuietlyhelpers.fetchReply().handleSelection.No config, schema, command-registration, or dependency changes.
Out of scope
MessageCreate(cleanerbut larger; retry covers the reported bug).
Generated by Coder Agents on behalf of @phorcys420.