Skip to content

feat: add gateway voice states and presences - #108

Merged
RedStar071 merged 1 commit into
feat/threadsfrom
feat/voice-presence
Sep 25, 2026
Merged

RedStar071 merged 1 commit into
feat/threadsfrom
feat/voice-presence

Conversation

@RedStar071

Copy link
Copy Markdown
Member

Stacked on #107.

🔗 Linked issue

Related to #54 (phase 10 of the roadmap).

🧭 Context

The cache already kept voice states and presences from the gateway, but nothing read them. There were no structures and no events, so a bot had no way to tell who was in a voice channel or what they were playing.

📚 Description

Voice states and presences follow discord.js, rebuilt from the pieces set aside at the start of #54 and adapted to the current design:

  • VoiceState has every field. It mutes, deafens, moves and disconnects the member through client.members.edit. In stage channels it handles setSuppressed and setRequestToSpeak, and the latter is only allowed on the bot's own state, as Discord requires.
  • Presence has the status, client status and Activitys, with RichPresenceAssets and their image URLs (application assets, Spotify, YouTube, Twitch).
  • client.voiceStates and client.presences are CachedManagers keyed by guild and user like members. They resolve the member, user and guild from the cache, and have listCached(guildId) for a guild's entries.
  • member.fetchVoiceState() and member.fetchPresence() replace discord.js's member.voice and member.presence.
  • Events: voiceStateUpdate and presenceUpdate, with the previous state from the cache.

Behavior to know:

  • Presences can't be fetched. They only come from the gateway, so client.presences.fetch rejects on a cache miss with a clear error, and member.fetchPresence() returns null.
  • member.fetchVoiceState() returns null for a disconnected member. Discord answers 404 (Unknown Voice State), which is treated as "not connected" instead of an error.

Key changes

Area Change
Structures VoiceState, Presence, Activity, RichPresenceAssets; GuildMember#fetchVoiceState/fetchPresence
Managers VoiceStateManager (client.voiceStates), PresenceManager (client.presences)
Events voiceStateUpdate, presenceUpdate

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

🟢 +5 new · 🟠 ~3 changed · 🔴 -0 removed · 2 flows · 15 files · commit b3f4b25


Architecture

Architecture diagram for wolfstar-project/plugins at b3f4b25

8 components touched across 5 lanes.

Play the interactive walkthrough


Inside the changed components — 2 views

Component view — Voice state management & stage controls

Voice state cache resolution, member mute/deafen/move mutations, and stage channel speaker controls.

Architecture view of Component view — Voice state management & stage controls in wolfstar-project/plugins

Component view — Presences, activities & rich assets

User presence dispatches, activity metadata, client platform statuses, and rich presence image URL formatting.

Architecture view of Component view — Presences, activities & rich assets in wolfstar-project/plugins

Data flow

Data flow diagram for wolfstar-project/plugins at b3f4b25

Receiving and dispatching voiceStateUpdate · Receiving and dispatching presenceUpdate

Follow each request, response and payload


The other flows — 1 sequence

Receiving and dispatching presenceUpdate

Sequence diagram of Receiving and dispatching presenceUpdate in wolfstar-project/plugins

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 every push. 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 on every push
  • 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 comment redraws for the new head. A slow older run never overwrites a newer one
  • 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

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

@wolfstar/plugin-cache

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

@wolfstar/plugin-gateway

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

@wolfstar/plugin-i18next

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

@wolfstar/plugin-logger

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

@wolfstar/plugin-subcommands-advanced

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

commit: b3f4b25

@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 adding voice states and presences to plugin-gateway, following discord.js's design and this repo's CachedManager/relation conventions.

  • VoiceState structure — every raw field, deaf/mute (server-or-self), fetchMember/fetchUser/fetchChannel, fetch() (re-patches from the API), setMute/setDeaf/setChannel/disconnect (via client.members.edit), and stage-only edit()/setSuppressed/setRequestToSpeak (rejects requestToSpeak for anyone but the bot's own state).
  • Presence structure — status, clientStatus, activities, resolved user/member/guild relations, and equals().
  • Activity/RichPresenceAssets — full field set, assets/smallImageURL/largeImageURL with per-platform (mp/spotify/youtube/twitch) URL building.
  • VoiceStateManager/PresenceManager — new CachedManager subclasses keyed guildId:userId; PresenceManager.fetchRaw always rejects (presences are gateway-only), VoiceStateManager.fetchRaw falls back to the GET /guilds/{guild}/voice-states/{user|@me} REST endpoint.
  • GuildMember#fetchVoiceState()/#fetchPresence(), new voiceStateUpdate/presenceUpdate dispatch handlers and events, README docs, and a changeset.

I cross-checked the third-party contracts this PR leans on rather than trusting them at face value: Routes.guildVoiceState's @me default and GET/PATCH support, APIVoiceState.guild_id being optional (DM/group calls — already filtered out by plugin-cache's VoiceStateUpdate handler before it would ever reach VoiceStateManager.keyOf's throw), GatewayPresenceUpdate.guild_id being required (so PresenceManager.keyOf correctly skips a null-guard), and DiscordAPIError.status. I also diffed Activity.equals(), Presence.equals(), and the RichPresenceAssets platform-URL asymmetry (small image only handles mp, large image also handles spotify/youtube/twitch) against discord.js's actual implementation — all match exactly. The new tests exercise real assertions (dispatch → event previous/current state, a 404-to-null fallback, cross-user setRequestToSpeak rejection) rather than tautologies.

No issues found.

Pullfrog  | View workflow run | Using Claude Sonnet | 𝕏

@RedStar071
RedStar071 added this pull request to stack #96 September 25, 2026 11:42
@RedStar071
RedStar071 force-pushed the feat/voice-presence branch 2 times, most recently from bcbd171 to c47a578 Compare September 25, 2026 17:28
@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 fb1bc9b into main Sep 25, 2026
16 of 17 checks passed
@RedStar071
RedStar071 deleted the feat/voice-presence 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