Repository navigation
feat(plugin-gateway): add resolveGuildEmoji - #236
Conversation
Finds a custom emoji by ID across every cached guild, like discord.js. MessagePayload now names files with the shared basename helper instead of its own node:path copy. Refs #159.
|
1 finding · reviewed 🟠
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: the full single-commit diff for plugin-gateway, checked against the surrounding GuildEmojiManager, Util.basename, MessagePayload.nameOf and the guildScopedKey key format.
resolveGuildEmoji: delegates to the new@internalGuildEmojiManager#findCachedInAnyGuild. Keys areguildId:emojiId, so theendsWith(":emojiId")scan is correct. Emoji IDs are unique, soslice(0, 1)before thegetcalls is safe.collectCachedrefactor:listCachedbehaviour is unchanged. The missing-store ([]) and non-iterable store (TypeError) paths are shared by both callers and covered by tests.MessagePayload.nameOf: now uses the sharedbasename. URLs still go throughnew URL().pathnamefirst, so fragments and empty paths behave as before. The newly cut?in local paths matchesUtil.basename, and the PR description calls it out.- Tests and changeset: multi-guild hit and miss, no-store and non-iterable store, and URL name cases are covered. The
minorchangeset fits a new public export.
claude-sonnet-5-5 | 𝕏

🔗 Linked issue
Refs #159
🧭 Context
#159 tracks what
@wolfstar/plugin-gatewaystill lacks from discord.js'sUtil.js. The Pullfrog plan on the issue splits the rest into four PRs; this is the first, the smallest slice:resolveGuildEmojiand the file-name helper duplication. The issue stays open for the other slices.📚 Description
resolveGuildEmoji(client, emojiId)finds a custom emoji by ID across every cached guild. Emojis are cached underguildId:emojiId, so there is no ID index; it enumerates the emoji cache and matches keys ending in:emojiId, the same wayGuildEmojiManager#listCacheddoes for one guild. It never calls the API, resolvesnullwhen no cached guild has the emoji or the entity is not cached, and throwsTypeErrorwhen the store cannot enumerate its entries.MessagePayloadkept a privatenameOf()built onnode:path. It now calls the sharedbasenamefromUtil.ts. URLs still go throughnew URL(...).pathnamefirst, so fragments are still dropped and an empty path still falls back tofile.jpg.Departures from the plan:
plugin-cache. The key scan matches whatlistCachedalready does and avoids a cache-format change for one helper.?is now cut at the?, as discord.js'sbasenamedoes. Before, only URLs were.Key changes
util/Util.ts: newresolveGuildEmoji.managers/GuildEmojiManager.ts:listCachedshares a privatecollectCachedwith the newfindCachedInAnyGuild(@internal).structures/messages/MessagePayload.ts:nameOfusesUtil.basename; thenode:pathimport is gone.serializers.test.ts), no store / non-iterable store (cached-manager.test.ts), URL query and fragment names (message-payload.test.ts).minorfor@wolfstar/plugin-gateway.Type of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.Verification:
pnpm build,pnpm typecheckandpnpm test(120 files, 1681 tests) pass. Rootpnpm lintfails locally onoxfmt --checkfor 269 files across all packages because this Windows checkout has CRLF line endings; that is not from this diff.oxfmt --check packages/plugin-gatewaypasses andoxlintreports no new warnings.