Repository navigation
feat: bring gateway channels and permission overwrites to discord.js parity - #105
Conversation
◈ PR LensPR Lens paused analysis for this repository — the fair-use limit was reached. It resumes automatically at 2026-09-25T18:00:00.000Z. |
@wolfstar/plugin-api
@wolfstar/plugin-cache
@wolfstar/plugin-gateway
@wolfstar/plugin-i18next
@wolfstar/plugin-logger
@wolfstar/plugin-subcommands-advanced
commit: |
There was a problem hiding this comment.
Important
One inline finding worth addressing before merge: lockPermissions can silently discard an explicit permissionOverwrites passed in the same edit() call.
Reviewed changes
Reviewed the full diff bringing @wolfstar/plugin-gateway guild channels to discord.js parity.
- Channel editing:
ChannelManager.edit/.delete,GuildChannelManager(create,fetch,edit,delete,setPositions), and per-type mixin setters (setName,setTopic,setRateLimitPerUser, voice/forum setters,setParent,lockPermissions,setPosition,clone), all funneled throughtoChannelBody/editChannel. - Permission overwrites: new
PermissionOverwriteManagerandPermissionOverwritesstructure;create/editPUT the overwrite and patch the gateway cache directly since the endpoint answers 204; target type is guessed from cached roles when omitted. - Channel permissions:
computeChannelPermissionsimplements Discord's documented overwrite order (administrator bypass →@everyone→ combined roles → member);channel.fetchPermissionsFor,member.fetchPermissionsIn,role.fetchPermissionsInwire it up, with threads resolving through their parent's overwrites.Message#hasPermissionnow uses channel-scoped permissions instead of guild-wide. - Tests:
tests/channels.test.tscovers overwrite computation order, admin bypass, overwrite CRUD (with exact PUT body assertions), setters,setParentoverwrite copying, delete cascade, andguild.channelscreate/move — assertions are specific (exact bodies, exact bitfields), not tautological.
I verified computeChannelPermissions's ordering against Discord's official permissions documentation (docs.discord.com/developers/topics/permissions) — it matches exactly (admin bypass, then @everyone deny/allow, then role deny/allow, then member deny/allow).
Claude Sonnet | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues — the earlier
lockPermissions/permissionOverwritesfinding from the previous review is still open and unaddressed.
Reviewed changes
The only change since the last review is a merge commit (1967d6a) syncing in the base branch (feat/reactions). The single content change it carries — Message's declare protected [kRelations] becoming declare public — originates from the base branch, not from this PR's channel/permission work, and isn't something to flag here.
Claude Sonnet | 𝕏
256e383 to
17afc6e
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the fix commit landed since the last pullfrog review, which closes the lockPermissions/permissionOverwrites finding from the previous review.
- Rejected combining
lockPermissionswith explicit overwrites:ChannelManager.editnow throws aTypeErrorup front when bothoptions.lockPermissionsandoptions.permissionOverwritesare passed, replacing the prior behavior wherelockPermissionssilently overwrote the caller's explicit overwrites with the parent category's. The JSDoc onGuildChannelEditOptions.lockPermissionswas updated to document the exclusivity, and a new test (GIVEN lockPermissions with explicit overwrites THEN edit rejects the call) asserts the rejection and that no REST call is made.
I traced every call site that reaches ChannelManager.edit (GuildChannelManager.edit, ChannelPermissionMixin.setParent, ChannelPermissionMixin.lockPermissions) — none of them pass both options together, so the guard only fires on a direct edit() call combining the two, exactly the scenario the prior review flagged. No new issues.
Claude Sonnet | 𝕏
17afc6e to
0195b8c
Compare
|
Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an Add repo secret → · Model settings → · Setup docs → · Ask in Discord →
|
0195b8c to
17e701c
Compare
|
Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an Add repo secret → · Model settings → · Setup docs → · Ask in Discord →
|

Stacked on #104.
🔗 Linked issue
Related to #54 (phase 8a of the roadmap).
🧭 Context
Channels could be fetched and deleted, but not edited. Their overwrites were a raw array, and permissions stopped at the guild level. So
member.fetchPermissions()ignored the channel entirely, and the messagefetch*able()checks said so in their docs.📚 Description
Guild channels now follow discord.js:
edit,setNameandcloneon every guild channel. The setters live on the mixin that owns each field:setTopic,setRateLimitPerUser,setBitrate/setUserLimit/setRTCRegion/setVideoQualityMode, and the forum ones (setAvailableTags,setDefaultReactionEmoji, ...).setParentcopies the category's overwrites by default, like discord.js.lockPermissionsandsetPositionare there too. Everything goes throughclient.channels.edit, which writes the result through_add.channel.permissionOverwritesis now aPermissionOverwriteManagerholdingPermissionOverwritesstructures.createreplaces an overwrite andeditkeeps the permissions you don't pass, taking{ Perm: true | false | null }like discord.js. With a plain ID and notype, it guesses: a cached role of the guild means a role, anything else a member. The overwrite endpoints answer 204, so the cached channel is patched in place.computeChannelPermissionsapplies overwrites the way Discord does: administrators skip them, then@everyone, then the roles combined, then the member. On top of it comechannel.fetchPermissionsFor(member | role | id),member.fetchPermissionsIn(channel)androle.fetchPermissionsIn(channel), the async versions of discord.js'spermissionsFor/permissionsIn. Threads use their parent's overwrites. The messagefetch*able()checks now use channel permissions.guild.channelsis aGuildChannelManagerwithcreate,fetch,edit,deleteandsetPositions. The positions endpoint answers 204, sosetPositionsrefetches the guild's channels rather than guessing how Discord shifted the others.channel.delete(reason)goes throughclient.channels.delete. It runs the same cache cascade asCHANNEL_DELETE(orTHREAD_DELETE), so the channel's messages leave the cache right away.One API change:
permissionOverwritesreturns a manager instead of the raw array. The package is unreleased, and the raw data is still reachable throughtoJSON(). Thread editing (archive, lock, members) is phase 9. Webhooks are 8b.Key changes
PermissionOverwrites; channel setters,clone,setParent,lockPermissions,setPosition,fetchPermissionsFor,fetchPermissionsLockedPermissionOverwriteManager,GuildChannelManager,client.channels.edit/delete/permissionOverwritescomputeChannelPermissions,member.fetchPermissionsIn,role.fetchPermissionsIn; message checks use channel permissionsutil/channels.ts: edit/create options,OverwriteData,resolveOverwriteOptionsType of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.