Skip to content

feat(plugin-gateway)!: match discord.js bulkDelete and Message typings - #206

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
t3code/plugin-gateway/bulk-delete-mixin
Oct 5, 2026
Merged

kodiakhq[bot] merged 2 commits into
mainfrom
t3code/plugin-gateway/bulk-delete-mixin

Conversation

@RedStar071

Copy link
Copy Markdown
Member

🔗 Linked issue

N/A. Follows the discord.js parity work tracked in the structure parity roadmap. equals() compatibility is left to #203.

🧭 Context

bulkDelete and Message diverged from discord.js 14.27: bulkDelete resolved to a plain ID list and lived on every text-based channel (Discord refuses it in DMs), PartialMessage was an intersection type guarded by Message#isPartial(), and Message had no InGuild generic.

📚 Description

Two parity changes, kept in one PR because the second reuses the PartialMessage type the first introduces and neither has been released yet.

  1. bulkDelete follows discord.js's TextBasedChannel#bulkDelete: it takes messages, IDs, a Collection or a count, throws MessageBulkDeleteType for anything else, and resolves to a Collection of the deleted messages by ID. It moves to the new TextGuildChannelMixin, so DMChannel and GroupDMChannel no longer have it.
  2. Message follows the discord.js typings (index.d.ts, Message): it is generic over InGuild, PartialMessage becomes a Partialize of Message with partial: true, and the missing members are added. The design is in docs/superpowers/specs/2026-10-05-message-types-parity-design.md, the steps in the matching plan.

Key changes

Area Before After
bulkDelete result string[] Collection<string, Message | PartialMessage | undefined>
bulkDelete on DM channels present removed
Message not generic Message<InGuild>, inGuild() narrows to Message<true>
PartialMessage Message & { partial: true }, isPartial() Partialize<Message, ...>, narrow with partial
Message#fetch always the API fetch(force), false reads the cache
Message#forward channel ID channel or channel ID
Message members sharedClientTheme, resolveComponent(), fetchWebhook(), MessageSnapshot, OmitPartialGroupDMChannel on the actions

Message#isPartial() was only on this unreleased branch, so it is removed without a shim. GuildMember#isPartial() is untouched.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Workflow / CI change

Pre-flight Checklist

  • I have read the Contributing Guidelines (if applicable)
  • My code follows the code style of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly
  • I added a changeset with pnpm changeset (or pnpm changeset add --empty if no release is needed). See .changeset/README.md.

🤖 AI disclosure: Claude Code was used on this PR. Code written with claude-sonnet-5-5; PR description written with claude-sonnet-5-5. AI policy.

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.
@coldtea-pr-lens

coldtea-pr-lens Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Note

This drawing shows 10654b8, and the branch has new commits since. Tick Redraw to draw the latest one

  • Redraw

Nothing flagged · reviewed 10654b8


Architecture

Architecture diagram for wolfstar-project/plugins at 10654b8

Play the walkthrough


Inside the changed components — 2 views

Component view — Message Parity & Structure

Message generic typing, PartialMessage discrimination, theme transformations, and webhook actions.

Architecture view of Component view — Message Parity & Structure in wolfstar-project/plugins

Component view — Bulk Delete & Guild Channel Mixins

Guild text channel mixins delegating bulk delete operations through MessageManager with cache integration.

Architecture view of Component view — Bulk Delete & Guild Channel Mixins in wolfstar-project/plugins

Data flow

Data flow diagram for wolfstar-project/plugins at 10654b8

Follow each request


The other flows — 1 sequence

Fetching message with cache check

Sequence diagram of Fetching message with cache check in wolfstar-project/plugins

View

  • Architecture lens
  • Data flow lens
  • Expand every detail

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
  • Run npx skills add coldteadotai/pr-lens, then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Run npx @coldtea/pr-lens-cli analyze --base origin/main on a branch, then npx @coldtea/pr-lens-cli render .pr-lens/graph.json. Same lenses, your own model key, before the pull request exists
  • Untick Architecture lens or Data flow lens under View to hide a diagram, or tick Expand every detail to open every section. The comment redraws in a few seconds
  • Click the link under each diagram to open it on a canvas you can zoom, pan and step through
  • The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change
  • The CLI's render reads .github/pr-lens.yml and applies your renames, exclusions and lane pins at draw time
  • Set github.comment.collapsed: true in .github/pr-lens.yml to fold the comment behind one View architecture and data flow row. Drawing still runs as before
  • Set github.draw: on-demand in .github/pr-lens.yml and PR Lens stops drawing pull requests on its own. Comment @pr-lens draw on a pull request when you want that one drawn
  • Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and your model provider's key as its api-key to run PR Lens from your own CI. Any /chat/completions endpoint works
  • Push a commit and the drawing stays, with a note that it is out of date. Tick Redraw in the note to draw the new head
  • Switch GitHub to dark mode and the diagrams follow. The moving dots are this pull request's data in motion

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.

❤️ Share

@wolfstarbot wolfstarbot added the packages:plugin-gateway Changes in plugin-gateway label Oct 5, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.

  • bulkDelete parity: accepts messages, IDs, a Collection or a count, throws MessageBulkDeleteType, and resolves to a Collection by ID. The cache is read before the request, so cached entries survive the delete.
  • TextGuildChannelMixin: moves bulkDelete off DMChannel and GroupDMChannel onto guild text, announcement, voice, stage and thread channels.
  • Message<InGuild>: adds the generic, inGuild() narrowing, PartialMessage as a Partialize, MessageSnapshot and OmitPartialGroupDMChannel on the actions.
  • New Message members: fetch(force), forward(channel | id), sharedClientTheme, resolveComponent() and fetchWebhook(), with the WebhookMessage and WebhookApplication errors.
  • 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#_partial takes a guildId that bulkDelete reads from the channel cache via guildIdOf, but no test checks that a partial from bulkDelete carries guildId (messages.test.ts only asserts id, channelId and partial). A createClient({ partials: [Partials.Message] }) case with a cached guild channel would cover it.

Pullfrog  | Fix it ➔ | View workflow run | Using claude-sonnet-5-5 | 𝕏

Also note in the changeset that event payloads still type uncached
messages as Message.
@pkg-pr-new

pkg-pr-new Bot commented Oct 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@wolfstar/plugin-api

pnpm add https://pkg.pr.new/@wolfstar/plugin-api@206

@wolfstar/plugin-broker

pnpm add https://pkg.pr.new/@wolfstar/plugin-broker@206

@wolfstar/plugin-cache

pnpm add https://pkg.pr.new/@wolfstar/plugin-cache@206

@wolfstar/plugin-gateway

pnpm add https://pkg.pr.new/@wolfstar/plugin-gateway@206

@wolfstar/plugin-i18next

pnpm add https://pkg.pr.new/@wolfstar/plugin-i18next@206

@wolfstar/plugin-logger

pnpm add https://pkg.pr.new/@wolfstar/plugin-logger@206

@wolfstar/plugin-scheduled-tasks

pnpm add https://pkg.pr.new/@wolfstar/plugin-scheduled-tasks@206

@wolfstar/plugin-sharder

pnpm add https://pkg.pr.new/@wolfstar/plugin-sharder@206

@wolfstar/plugin-subcommands-advanced

pnpm add https://pkg.pr.new/@wolfstar/plugin-subcommands-advanced@206

commit: e9d0f50

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Incremental review of e9d0f50 against the prior pullfrog review at 10654b8.

  • Guild propagation test: messages.test.ts now covers a bulkDelete in a cached guild channel with Partials.Message and asserts deleted.get(fresher)!.guildId is guildId. The assertion is exact, so it fails if _partial loses the guild. I ran the file: 44 passing.
  • Event typing note: the message-types-discordjs-parity changeset now states that messageUpdate, messageDelete, messageDeleteBulk and the reaction events still type partial messages as Message, with widening to Message | PartialMessage left to a follow-up. That settles the design note from the last review.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@kodiakhq
kodiakhq Bot merged commit 9f3c365 into main Oct 5, 2026
17 checks passed
@kodiakhq
kodiakhq Bot deleted the t3code/plugin-gateway/bulk-delete-mixin branch October 5, 2026 18:16
RedStar071 pushed a commit that referenced this pull request Oct 30, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages:plugin-gateway Changes in plugin-gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants