Repository navigation
feat(plugin-gateway)!: align equals() with discord.js across structures - #218
Conversation
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
|
✅ Clean pass · Architecture Inside the changed components — 3 viewsComponent view — Message & Embed Equality Parity Equality checks for Message and Embed instances with field-by-field payload normalization Component view — Guild & Channel Structure Equality Equality comparison methods for channels, guilds, guild members, roles, and users Component view — Emojis, Stickers & Soundboard Parity Equality evaluation for custom emojis, guild stickers, and soundboard sounds Data flow View
Tip Set 🪧 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 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#equalsfollows the discord.js shape (ID, author, content,nonce,tts, attachments by ID, embeds viaEmbed#equals,rawDatafor mentions and timestamps).Embed#equalsdeep-compares two embeds and compares field by field against a raw one.Guild/GuildMember/Role/User: field sets realigned, withunknownparams for the first two so a foreign argument returnsfalse.Sticker/GuildEmoji: structure vs raw comparisons split as in discord.js.Stickerusesformat, which is a primitive alias offormatType, so thediff()helper inutil/dispatch.tsdoes not produce spurious updates.GuildChannelMixin#equals(new): reuses the now-exportedsameOverwrites, 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 updatedmessages.test.ts, and aminorchangeset, 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 theparentparameter name is misleading (otherwould fit).packages/plugin-gateway/tests/messages.test.ts: the deliberate divergence from discord.js (edited_timestampnullequalsnullfor a never-edited message whenrawDatais passed) has no test. TherawDatatest only uses an edited message, so a regression toDate.parse(null)(NaN) would not be caught.- The PR description ticks both "New feature (non-breaking change)" and "Breaking change". The
!and theminorchangeset at 0.10.0 are consistent with breaking, so the first box could be unticked.
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
Resolves #203
🧭 Context
In discord.js
equals()is a convention shared by many structures.@wolfstar/plugin-gatewayhad 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 (thev14branch andmain).📚 Description
Every
equals()now compares what discord.js compares. v14 and v15 share the implementations, apart from two fields (v15 addspremiumSinceTimestampto the member and dropsavatarDecorationfrom the user); this follows v15.Deliberate differences from discord.js:
falsewhere discord.js would throw onnullor a wrong type.Message#equalswithrawData: discord.js compareseditedTimestampwithDate.parse(null), which isNaN, so a never-edited message is never equal. Herenullequalsnull.equalstoo, because the guild channel mixin is shared. In discord.jsThreadChannelhas none.Not ported:
ApplicationEmojiandApplicationCommandhave no structure here (tracked in #207, #208 and #209), andUser#_equalsis private in discord.js.Update events are unaffected, except
emojiUpdateandstickerUpdate, which already went throughequalsand still do: no other handler inutil/dispatch.tscalls it.The type-level consumption test was not extended for the new signatures.
Key changes
Messagenonce,tts, attachments by ID, and embeds throughEmbed#equals; optionalrawDataaddsmention_everyoneand the timestamps.pinnedis no longer compared.Embedtypeignored, a missinginlineisfalse).Guildavailable,memberCount,large, features in order. Drops the AFK and system channels, content filter, MFA level, banner, description, vanity code.GuildMemberpartial, banner,pending, avatar decoration, nameplate; roles in order.Rolecolorsinstead ofcolor.UserStickerGuildEmojiGuildChannel(new)SoundboardSound(new)Presence,Activity,ComponentandBitFieldalready matched and are unchanged.Tests: new
tests/equals.test.ts, updatedtests/messages.test.ts.Type of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.