Repository navigation
feat(plugin-gateway)!: match discord.js bulkDelete and Message typings - #206
Conversation
bulkDelete resolves to a Collection and moves to TextGuildChannelMixin, and Message becomes generic with a partial discriminant, MessageSnapshot, OmitPartialGroupDMChannel and the missing fetch(force), sharedClientTheme, resolveComponent and fetchWebhook members.
|
Note This drawing shows
Nothing flagged · reviewed Architecture Inside the changed components — 2 viewsComponent view — Message Parity & Structure Message generic typing, PartialMessage discrimination, theme transformations, and webhook actions. Component view — Bulk Delete & Guild Channel Mixins Guild text channel mixins delegating bulk delete operations through MessageManager with cache integration. Data flow The other flows — 1 sequence
View
Tip Open a diagram on the canvas, then press W or click play to walk through the change one step at a time 🪧 More tips
Thanks for using PR Lens! It's built by Coldtea, free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
ℹ️ No critical issues — one design note and one test gap.
Reviewed changes
Full review of the single commit. I ran messages.test.ts (43 passing) and the plugin-gateway consumption typecheck (clean after building plugin-cache). I skimmed the plan and spec docs only for convention, not content.
bulkDeleteparity: accepts messages, IDs, aCollectionor a count, throwsMessageBulkDeleteType, and resolves to aCollectionby ID. The cache is read before the request, so cached entries survive the delete.TextGuildChannelMixin: movesbulkDeleteoffDMChannelandGroupDMChannelonto guild text, announcement, voice, stage and thread channels.Message<InGuild>: adds the generic,inGuild()narrowing,PartialMessageas aPartialize,MessageSnapshotandOmitPartialGroupDMChannelon the actions.- New
Messagemembers:fetch(force),forward(channel | id),sharedClientTheme,resolveComponent()andfetchWebhook(), with theWebhookMessageandWebhookApplicationerrors. - Tests and docs: runtime tests, type-level tests, README, two changesets and the plan and spec docs.
ℹ️ Message#partial is typed false, but events still hand out partial messages typed as Message
bulkDelete is now the only place that returns a PartialMessage. messageDelete, messageUpdate, messageDeleteBulk and the reaction events build their partial messages through partialMessage() in util/dispatch.ts and cast them back to Message. With Partials.Message on, message.content is therefore typed string and message.partial is typed false while both are wrong at runtime. The README Partials example (if (message?.partial)) still compiles, which I checked, but TypeScript treats the branch as unreachable. This is a deliberate trade-off (the code comment says so), so it is a call for the author, not a defect. Widening those events to Message | PartialMessage would follow discord.js, but it is a breaking change for listeners.
Technical details
# Event payloads vs. `PartialMessage`
## Affected sites
- packages/plugin-gateway/src/util/dispatch.ts:910 — `partialMessage()` casts `PartialMessage | null` to `Message | null`
- packages/plugin-gateway/src/util/events.ts:203-205 — `messageUpdate`, `messageDelete`, `messageDeleteBulk` typed with `Message`
- packages/plugin-gateway/src/structures/messages/Message.ts:654 — `partial` typed `false`
## Required outcome
- Decide whether events should type uncached messages as `Message | PartialMessage`, now or in a follow-up, and note the intended path in the PR or changeset.ℹ️ Nitpicks
MessageManager#_partialtakes aguildIdthatbulkDeletereads from the channel cache viaguildIdOf, but no test checks that a partial frombulkDeletecarriesguildId(messages.test.tsonly assertsid,channelIdandpartial). AcreateClient({ partials: [Partials.Message] })case with a cached guild channel would cover it.
claude-sonnet-5-5 | 𝕏
Also note in the changeset that event payloads still type uncached messages as Message.
@wolfstar/plugin-api
@wolfstar/plugin-broker
@wolfstar/plugin-cache
@wolfstar/plugin-gateway
@wolfstar/plugin-i18next
@wolfstar/plugin-logger
@wolfstar/plugin-scheduled-tasks
@wolfstar/plugin-sharder
@wolfstar/plugin-subcommands-advanced
commit: |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Incremental review of e9d0f50 against the prior pullfrog review at 10654b8.
- Guild propagation test:
messages.test.tsnow covers abulkDeletein a cached guild channel withPartials.Messageand assertsdeleted.get(fresher)!.guildIdisguildId. The assertion is exact, so it fails if_partialloses the guild. I ran the file: 44 passing. - Event typing note: the
message-types-discordjs-paritychangeset now states thatmessageUpdate,messageDelete,messageDeleteBulkand the reaction events still type partial messages asMessage, with widening toMessage | PartialMessageleft to a follow-up. That settles the design note from the last review.
claude-sonnet-5-5 | 𝕏
Review of PRs merged in the last 7 days surfaced two established conventions missing from AGENTS.md: the knip unused-code/dependency check (devDependency and CI job since the repo's first commit, touched again in #232) has no root script and was undocumented, and recent structural-change PRs (#206, #218, and earlier parity work) consistently link a plan/spec under docs/superpowers/ that AGENTS.md never mentioned.

🔗 Linked issue
N/A. Follows the discord.js parity work tracked in the structure parity roadmap.
equals()compatibility is left to #203.🧭 Context
bulkDeleteandMessagediverged from discord.js 14.27:bulkDeleteresolved to a plain ID list and lived on every text-based channel (Discord refuses it in DMs),PartialMessagewas an intersection type guarded byMessage#isPartial(), andMessagehad noInGuildgeneric.📚 Description
Two parity changes, kept in one PR because the second reuses the
PartialMessagetype the first introduces and neither has been released yet.bulkDeletefollows discord.js'sTextBasedChannel#bulkDelete: it takes messages, IDs, aCollectionor a count, throwsMessageBulkDeleteTypefor anything else, and resolves to aCollectionof the deleted messages by ID. It moves to the newTextGuildChannelMixin, soDMChannelandGroupDMChannelno longer have it.Messagefollows the discord.js typings (index.d.ts,Message): it is generic overInGuild,PartialMessagebecomes aPartializeofMessagewithpartial: true, and the missing members are added. The design is indocs/superpowers/specs/2026-10-05-message-types-parity-design.md, the steps in the matching plan.Key changes
bulkDeleteresultstring[]Collection<string, Message | PartialMessage | undefined>bulkDeleteon DM channelsMessageMessage<InGuild>,inGuild()narrows toMessage<true>PartialMessageMessage & { partial: true },isPartial()Partialize<Message, ...>, narrow withpartialMessage#fetchfetch(force),falsereads the cacheMessage#forwardMessagememberssharedClientTheme,resolveComponent(),fetchWebhook(),MessageSnapshot,OmitPartialGroupDMChannelon the actionsMessage#isPartial()was only on this unreleased branch, so it is removed without a shim.GuildMember#isPartial()is untouched.Type of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.