Skip to content

feat(plugin-gateway)!: align equals() with discord.js across structures - #218

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
t3code/implement-issue-203
Oct 6, 2026
Merged

kodiakhq[bot] merged 1 commit into
mainfrom
t3code/implement-issue-203

Conversation

@RedStar071

Copy link
Copy Markdown
Member

🔗 Linked issue

Resolves #203

🧭 Context

In discord.js equals() is a convention shared by many structures. @wolfstar/plugin-gateway had most of them, but with comparisons that drifted from discord.js, and two were missing (GuildChannel, SoundboardSound). Pullfrog's plan on the issue recalled the discord.js semantics from memory; this PR ports them from the actual source instead (the v14 branch and main).

📚 Description

Every equals() now compares what discord.js compares. v14 and v15 share the implementations, apart from two fields (v15 adds premiumSinceTimestamp to the member and drops avatarDecoration from the user); this follows v15.

Deliberate differences from discord.js:

  • Foreign arguments return false where discord.js would throw on null or a wrong type.
  • Message#equals with rawData: discord.js compares editedTimestamp with Date.parse(null), which is NaN, so a never-edited message is never equal. Here null equals null.
  • Channel overwrites are compared by data (ID, type, allow, deny). discord.js compares the overwrite objects by identity.
  • Threads get equals too, because the guild channel mixin is shared. In discord.js ThreadChannel has none.

Not ported: ApplicationEmoji and ApplicationCommand have no structure here (tracked in #207, #208 and #209), and User#_equals is private in discord.js.

Update events are unaffected, except emojiUpdate and stickerUpdate, which already went through equals and still do: no other handler in util/dispatch.ts calls it.

The type-level consumption test was not extended for the new signatures.

Key changes

Structure Change
Message Compares the ID, author, content, nonce, tts, attachments by ID, and embeds through Embed#equals; optional rawData adds mention_everyone and the timestamps. pinned is no longer compared.
Embed Deep comparison between two embeds; field-by-field against a raw embed (type ignored, a missing inline is false).
Guild Adds available, memberCount, large, features in order. Drops the AFK and system channels, content filter, MFA level, banner, description, vanity code.
GuildMember Adds partial, banner, pending, avatar decoration, nameplate; roles in order.
Role The three colors instead of color.
User Adds the avatar decoration SKU, nameplate, primary guild.
Sticker Adds type, pack and sort value against a sticker; ID, description, name and tags against a raw one.
GuildEmoji ID, name and roles against a raw emoji.
GuildChannel (new) ID, type, topic, position, name, overwrites. The category is not compared, as in discord.js.
SoundboardSound (new) Same fields as discord.js, structure or raw payload.

Presence, Activity, Component and BitField already matched and are unchanged.

Tests: new tests/equals.test.ts, updated tests/messages.test.ts.

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 and claude-opus-5-5; PR description written with claude-opus-5-5. AI policy.

Port every equals() from discord.js (v14 and v15 share the comparisons):
Message, Embed, Guild, GuildMember, Role, User, Sticker and GuildEmoji now
compare the same fields, and GuildChannel and SoundboardSound gain the
method. Foreign arguments return false instead of throwing.

Resolves #203
@coldtea-pr-lens

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

Copy link
Copy Markdown

✅ Clean pass · 99036be looks sound on architecture, data flow and security


Architecture

Architecture diagram for wolfstar-project/plugins at 99036be

Play the walkthrough


Inside the changed components — 3 views

Component view — Message & Embed Equality Parity

Equality checks for Message and Embed instances with field-by-field payload normalization

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

Component view — Guild & Channel Structure Equality

Equality comparison methods for channels, guilds, guild members, roles, and users

Architecture view of Component view — Guild & Channel Structure Equality in wolfstar-project/plugins

Component view — Emojis, Stickers & Soundboard Parity

Equality evaluation for custom emojis, guild stickers, and soundboard sounds

Architecture view of Component view — Emojis, Stickers & Soundboard Parity in wolfstar-project/plugins

Data flow

Data flow diagram for wolfstar-project/plugins at 99036be

Follow each request


View

  • Architecture lens
  • Data flow lens
  • Expand every detail

Tip

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

🪧 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
  • Open a diagram on the canvas, then press W or click play to walk through the change one step at a time
  • 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
  • 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 6, 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 new issues found.

Reviewed changes

Reviewed the full diff of the single commit against main, ran equals.test.ts and messages.test.ts (67 tests pass) and pnpm lint (clean).

  • Message / Embed: Message#equals follows the discord.js shape (ID, author, content, nonce, tts, attachments by ID, embeds via Embed#equals, rawData for mentions and timestamps). Embed#equals deep-compares two embeds and compares field by field against a raw one.
  • Guild / GuildMember / Role / User: field sets realigned, with unknown params for the first two so a foreign argument returns false.
  • Sticker / GuildEmoji: structure vs raw comparisons split as in discord.js. Sticker uses format, which is a primitive alias of formatType, so the diff() helper in util/dispatch.ts does not produce spurious updates.
  • GuildChannelMixin#equals (new): reuses the now-exported sameOverwrites, so overwrites compare by data in any order; this also covers threads.
  • SoundboardSound#equals (new): accepts the structure or a raw payload.
  • Tests and changeset: a new tests/equals.test.ts, an updated messages.test.ts, and a minor changeset, which is breaking at 0.10.0.

ℹ️ Nitpicks

  • packages/plugin-gateway/src/structures/channels/mixins/ChannelPermissionMixin.ts:27: sameOverwrites(channel, parent) is now exported and used to compare any two channels, so the parent parameter name is misleading (other would fit).
  • packages/plugin-gateway/tests/messages.test.ts: the deliberate divergence from discord.js (edited_timestamp null equals null for a never-edited message when rawData is passed) has no test. The rawData test only uses an edited message, so a regression to Date.parse(null) (NaN) would not be caught.
  • The PR description ticks both "New feature (non-breaking change)" and "Breaking change". The ! and the minor changeset at 0.10.0 are consistent with breaking, so the first box could be unticked.

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

@kodiakhq
kodiakhq Bot merged commit f1c99b5 into main Oct 6, 2026
18 checks passed
@kodiakhq
kodiakhq Bot deleted the t3code/implement-issue-203 branch October 6, 2026 11:17
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.

plugin-gateway: structure compatibility of equals() across structures (discord.js parity)

2 participants