Skip to content

feat: bring gateway channels and permission overwrites to discord.js parity - #105

Merged
RedStar071 merged 2 commits into
feat/reactionsfrom
feat/channels
Sep 25, 2026
Merged

RedStar071 merged 2 commits into
feat/reactionsfrom
feat/channels

Conversation

@RedStar071

Copy link
Copy Markdown
Member

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 message fetch*able() checks said so in their docs.

📚 Description

Guild channels now follow discord.js:

  • Editing. edit, setName and clone on 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, ...). setParent copies the category's overwrites by default, like discord.js. lockPermissions and setPosition are there too. Everything goes through client.channels.edit, which writes the result through _add.
  • Overwrites. channel.permissionOverwrites is now a PermissionOverwriteManager holding PermissionOverwrites structures. create replaces an overwrite and edit keeps the permissions you don't pass, taking { Perm: true | false | null } like discord.js. With a plain ID and no type, 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.
  • Permissions. computeChannelPermissions applies overwrites the way Discord does: administrators skip them, then @everyone, then the roles combined, then the member. On top of it come channel.fetchPermissionsFor(member | role | id), member.fetchPermissionsIn(channel) and role.fetchPermissionsIn(channel), the async versions of discord.js's permissionsFor/permissionsIn. Threads use their parent's overwrites. The message fetch*able() checks now use channel permissions.
  • guild.channels is a GuildChannelManager with create, fetch, edit, delete and setPositions. The positions endpoint answers 204, so setPositions refetches the guild's channels rather than guessing how Discord shifted the others.
  • channel.delete(reason) goes through client.channels.delete. It runs the same cache cascade as CHANNEL_DELETE (or THREAD_DELETE), so the channel's messages leave the cache right away.

One API change: permissionOverwrites returns a manager instead of the raw array. The package is unreleased, and the raw data is still reachable through toJSON(). Thread editing (archive, lock, members) is phase 9. Webhooks are 8b.

Key changes

Area Change
Structures PermissionOverwrites; channel setters, clone, setParent, lockPermissions, setPosition, fetchPermissionsFor, fetchPermissionsLocked
Managers PermissionOverwriteManager, GuildChannelManager, client.channels.edit/delete/permissionOverwrites
Permissions computeChannelPermissions, member.fetchPermissionsIn, role.fetchPermissionsIn; message checks use channel permissions
Utils util/channels.ts: edit/create options, OverwriteData, resolveOverwriteOptions

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: Wolfstar Agent Kit modified this description. My AI open-source policy.

@coldtea-pr-lens

coldtea-pr-lens Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

◈ PR Lens

PR Lens paused analysis for this repository — the fair-use limit was reached. It resumes automatically at 2026-09-25T18:00:00.000Z.

@pkg-pr-new

pkg-pr-new Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@wolfstar/plugin-api

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-api@105

@wolfstar/plugin-cache

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-cache@105

@wolfstar/plugin-gateway

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-gateway@105

@wolfstar/plugin-i18next

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-i18next@105

@wolfstar/plugin-logger

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-logger@105

@wolfstar/plugin-subcommands-advanced

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-subcommands-advanced@105

commit: 17e701c

@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.

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 through toChannelBody/editChannel.
  • Permission overwrites: new PermissionOverwriteManager and PermissionOverwrites structure; create/edit PUT the overwrite and patch the gateway cache directly since the endpoint answers 204; target type is guessed from cached roles when omitted.
  • Channel permissions: computeChannelPermissions implements Discord's documented overwrite order (administrator bypass → @everyone → combined roles → member); channel.fetchPermissionsFor, member.fetchPermissionsIn, role.fetchPermissionsIn wire it up, with threads resolving through their parent's overwrites. Message#hasPermission now uses channel-scoped permissions instead of guild-wide.
  • Tests: tests/channels.test.ts covers overwrite computation order, admin bypass, overwrite CRUD (with exact PUT body assertions), setters, setParent overwrite copying, delete cascade, and guild.channels create/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).

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Claude Sonnet | 𝕏

@RedStar071 RedStar071 mentioned this pull request Sep 24, 2026
6 of 11 tasks

@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 — the earlier lockPermissions/permissionOverwrites finding 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.

Pullfrog  | Fix it ➔ | View workflow run | Using Claude Sonnet | 𝕏

@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

This run reviewed the fix commit landed since the last pullfrog review, which closes the lockPermissions/permissionOverwrites finding from the previous review.

  • Rejected combining lockPermissions with explicit overwrites: ChannelManager.edit now throws a TypeError up front when both options.lockPermissions and options.permissionOverwrites are passed, replacing the prior behavior where lockPermissions silently overwrote the caller's explicit overwrites with the parent category's. The JSDoc on GuildChannelEditOptions.lockPermissions was 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.

Pullfrog  | View workflow run | Using Claude Sonnet | 𝕏

@pullfrog

pullfrog Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an ANTHROPIC_API_KEY repo secret — Pullfrog routes around an exhausted subscription automatically when one is present.

Add repo secret → · Model settings → · Setup docs → · Ask in Discord →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using Claude Sonnet | 𝕏

@pullfrog

pullfrog Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an ANTHROPIC_API_KEY repo secret — Pullfrog routes around an exhausted subscription automatically when one is present.

Add repo secret → · Model settings → · Setup docs → · Ask in Discord →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using Claude Sonnet | 𝕏

@RedStar071
RedStar071 merged commit c7f73dc into main Sep 25, 2026
18 of 25 checks passed
@RedStar071
RedStar071 deleted the feat/channels branch September 25, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant