Repository navigation
feat(plugin-gateway): resolve messages and attachments in transformResolved - #249
Merged
Merged
Conversation
…mentioned users transformResolved resolves messages (IDs from the cache of the new channelId option, raw data to the cached message or a built one) and attachments (built as Attachment), like discord.js. MessageMentions#parsedUsers includes the users the payload mentions even when uncached, without writing the cache. Document why MessagePayload keeps its URL-aware file name helper.
|
Architecture Data flow ReviewNothing flagged · reviewed Tip Run 🪧 More tips
Thanks for using PR Lens! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
6 tasks
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the full single-commit diff, plus the surrounding resolveEach, CachedManager#_resolveData, MessageMentions and Attachment code. I ran the three touched test files locally (util, relations-messages, message-payload): 65 tests pass.
transformResolvedmessages/attachments —messagesread IDs from the cache of the newchannelIdoption, and raw data resolves to the cached message or is built from the data.attachmentsare always built asAttachment. Nothing is written to the cache.- Mentioned users from the payload —
MessageManager#resolveMentionsnow passes the payload's raw users (withoutmember) soMessageMentions#parsedUsersandcleanContentinclude uncached mentioned users._resolveDatastill prefers a cached copy, so a cached user wins over the payload's. MessagePayloadnameOf()— a comment documents why it differs fromfindName, and a query-with-slash test case was added.- Changeset — a
minorbump for@wolfstar/plugin-gateway.
claude-sonnet-5-5 | 𝕏
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.

🔗 Linked issue
Refs #159 (partial: the position follow-ups remain open, so the issue stays open)
🧭 Context
#159 tracks the discord.js
Utilhelpers@wolfstar/plugin-gatewaystill lacks.resolveGuildEmojimerged in #236; this PR takes thetransformResolved/ mentions follow-ups and settles the small leftover decisions. The computedRole#position/GuildChannel#position,fetchSortedfrom the cache, andrelativeentries onsetPositionsare design-heavy and left for a later PR.📚 Description
I re-checked every checklist item and the Pullfrog findings against current
mainfirst:MessagePayloadfile names: it already importsbasenamefromutil/Util.ts; only the URL pre-handling in the localnameOf()is separate.findNametakes the last path segment of the whole string, so it would keep#fragment, namehttps://cdn.example/after its host, and mis-name?next=/a/b. The existing contract (message-payload.test.ts) requires the opposite, so I keptnameOf(), documented why, and added a query-with-slash case.messages/attachments: the Pullfrog plan put them onMessageMentions, but discord.js'sMessageMentionshas neither. The issue text is abouttransformResolved(the interactionresolvedpayload), so they are added there:messages(IDs read from the cache of a newchannelIdoption, raw data resolved to the cached message or built from it) andattachments(built asAttachment). Nothing is written to the cache.MessageMentions#usersand#membersalready fall back to the payload. discord.js'sparsedUsersonly reads the cache, but discord.js caches the payload's mentioned users first, so they show up there. The message manager now hands those raw users totransformResolved, soparsedUsersincludes them without writing the cache; content-only mentions stay cache-only, as in discord.js. This also feedscleanContent.GuildMemberRoleManager: left alone.discordSort(roles).reverse()gives the same order, but needs a second array copy and relies ondiscordSorttelling roles from channels by whether the first item has atype, so it is not a simplification.flatten/resolveSKUId: kept as exported public util API;resolveSKUIdgets a consumer with the monetization work.Key changes
transformResolvedmessages,attachmentsdata andchannelIdcontext option,messages/attachmentsin the resultMessageManagerMessageMentions#parsedUsersincludes themMessagePayloadnameOf()documented as an intentional difference fromfindNameutil.test.ts,relations-messages.test.ts,message-payload.test.ts@wolfstar/plugin-gatewayminorStill open on #159: computed sorted
positionwithrawPosition, sorting cached channels/roles without refetching, andrelativeentries onsetPositions.Verification:
pnpm lint(oxlint: no errors;oxfmt --checkpasses with CRLF line endings, as git on Windows checks files out; the LF index is normalised on commit),pnpm build,pnpm typecheckandpnpm test(121 files, 1716 tests) all pass locally.Type of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.