Skip to content

feat(plugin-gateway): add category.children and answer.voters managers - #222

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
feat/plugin-gateway-category-children-poll-voters
Oct 6, 2026
Merged

kodiakhq[bot] merged 1 commit into
mainfrom
feat/plugin-gateway-category-children-poll-voters

Conversation

@RedStar071

Copy link
Copy Markdown
Member

🔗 Linked issue

Refs #216

🧭 Context

Second PR of the discord.js manager parity work tracked in #216 (the issue stays open). PR 1 (#221) added the small manager methods; this one adds the two scoped managers that hang off a category and a poll answer. Every new file in src/managers/ has Manager in its name, as in #219.

📚 Description

CategoryChannel#children returns a CategoryChannelChildManager and PollAnswer#voters returns a PollAnswerVoterManager, built on access like channel.threads.

  • children.cache has no cache of its own: it is read from the raw channel store on each access (through an internal ChannelManager#_inCategory), so it always agrees with client.channels. It is synchronous with a synchronous cache and a promise with an asynchronous one (CacheRead). A store that cannot enumerate throws CacheNotIterable, like listCached.
  • children.create() creates the channel through guild.channels.create with the category as parent.
  • voters.fetch() delegates to MessageManager#fetchPollAnswerVoters; PollAnswer#fetchVoters now goes through it.

Deviations from the plan on the issue:

  • create() takes options without parent and without the category type, and a category type passed anyway throws the new CategoryChildCategory error before any request. The plan only said to inject parent_id.
  • answer.voters has no cache: nothing tracks the voters of an answer, so each fetch reads the API.
  • children is a BaseManager, not a DataManager, since its cache is derived (the GuildMemberRoleManager precedent), so there is no fetch/refresh.

Design notes are in docs/superpowers/specs/2026-10-06-category-children-poll-voters-design.md.

Key changes

Member Behaviour
CategoryChannel#children CategoryChannelChildManager: cache, guild, create, resolve, resolveId, valueOf
PollAnswer#voters PollAnswerVoterManager: fetch({ limit, after })
ChannelManager#_inCategory (internal) Cached non-thread channels of a guild with the given parent_id
CategoryChildCategory (error) Thrown by create for a category type

Verification: pnpm lint, pnpm build, pnpm typecheck and pnpm test (110 files, 1526 tests) all pass locally. The new tests run against a synchronous cache, the default cache and an asynchronous store; tests/types/category-children.ts is the type-level check.

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.

Add CategoryChannelChildManager (cache, create with the category as parent,
resolve) behind CategoryChannel#children, and PollAnswerVoterManager (fetch)
behind PollAnswer#voters, after discord.js. children.cache is read from the
channel store, so it stays in step with client.channels.

Refs #216
@coldtea-pr-lens

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

Copy link
Copy Markdown

Nothing flagged · reviewed 0a3eefa


Architecture

Architecture diagram for wolfstar-project/plugins at 0a3eefa

Play the walkthrough


Inside the changed components — 2 views

Component view — Category children

Internal components managing category child channels, cache enumeration, and channel creation.

Architecture view of Component view — Category children in wolfstar-project/plugins

Component view — Poll answer voters

Internal components handling poll answer voter fetching, Discord REST queries, and user caching.

Architecture view of Component view — Poll answer voters in wolfstar-project/plugins

Data flow

Data flow diagram for wolfstar-project/plugins at 0a3eefa

Follow each request


The other flows — 1 sequence

Fetching poll answer voters

Sequence diagram of Fetching poll answer voters in wolfstar-project/plugins

View

  • Architecture lens
  • Data flow lens
  • Expand every detail

Tip

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

🪧 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
  • 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
  • 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: the full diff of the single commit, checked against the existing ChannelManager/CachedManager cache helpers.

  • CategoryChannelChildManager: a BaseManager whose cache is derived from the raw channel store on each read, plus create, resolve, resolveId, valueOf and guild.
  • ChannelManager#_inCategory: an internal enumeration that follows the same iterableCache() + guard("entries") + whenAll pattern as _countInGuild, so it stays synchronous with a synchronous cache and throws CacheNotIterable for a non-enumerable store.
  • PollAnswerVoterManager: delegates fetch to MessageManager#fetchPollAnswerVoters; PollAnswer#fetchVoters now routes through it.
  • CategoryChildCategory error: create rejects a category type before any request, and the options type omits parent and the category type.
  • Tests, changeset and spec: runtime tests across synchronous, default and asynchronous caches, a type-level consumption test, a minor changeset, and a design spec consistent with the existing docs/superpowers/specs/ entries.

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

@kodiakhq
kodiakhq Bot merged commit ff72647 into main Oct 6, 2026
18 checks passed
@kodiakhq
kodiakhq Bot deleted the feat/plugin-gateway-category-children-poll-voters branch October 6, 2026 12:19
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