Repository navigation
feat: add gateway voice states and presences - #108
Conversation
◈ PR Lens
Architecture 8 components touched across 5 lanes. Play the interactive walkthrough Inside the changed components — 2 viewsComponent view — Voice state management & stage controls Voice state cache resolution, member mute/deafen/move mutations, and stage channel speaker controls. Component view — Presences, activities & rich assets User presence dispatches, activity metadata, client platform statuses, and rich presence image URL formatting. Data flow
Follow each request, response and payload The other flows — 1 sequence
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. |
@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.
✅ 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.
VoiceStatestructure — every raw field,deaf/mute(server-or-self),fetchMember/fetchUser/fetchChannel,fetch()(re-patches from the API),setMute/setDeaf/setChannel/disconnect(viaclient.members.edit), and stage-onlyedit()/setSuppressed/setRequestToSpeak(rejectsrequestToSpeakfor anyone but the bot's own state).Presencestructure —status,clientStatus,activities, resolveduser/member/guildrelations, andequals().Activity/RichPresenceAssets— full field set,assets/smallImageURL/largeImageURLwith per-platform (mp/spotify/youtube/twitch) URL building.VoiceStateManager/PresenceManager— newCachedManagersubclasses keyedguildId:userId;PresenceManager.fetchRawalways rejects (presences are gateway-only),VoiceStateManager.fetchRawfalls back to theGET /guilds/{guild}/voice-states/{user|@me}REST endpoint.GuildMember#fetchVoiceState()/#fetchPresence(), newvoiceStateUpdate/presenceUpdatedispatch 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.
Claude Sonnet | 𝕏
bcbd171 to
c47a578
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 →
|
c47a578 to
b3f4b25
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 #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:
VoiceStatehas every field. It mutes, deafens, moves and disconnects the member throughclient.members.edit. In stage channels it handlessetSuppressedandsetRequestToSpeak, and the latter is only allowed on the bot's own state, as Discord requires.Presencehas the status, client status andActivitys, withRichPresenceAssetsand their image URLs (application assets, Spotify, YouTube, Twitch).client.voiceStatesandclient.presencesareCachedManagers keyed by guild and user like members. They resolve the member, user and guild from the cache, and havelistCached(guildId)for a guild's entries.member.fetchVoiceState()andmember.fetchPresence()replace discord.js'smember.voiceandmember.presence.voiceStateUpdateandpresenceUpdate, with the previous state from the cache.Behavior to know:
client.presences.fetchrejects on a cache miss with a clear error, andmember.fetchPresence()returnsnull.member.fetchVoiceState()returnsnullfor a disconnected member. Discord answers 404 (Unknown Voice State), which is treated as "not connected" instead of an error.Key changes
VoiceState,Presence,Activity,RichPresenceAssets;GuildMember#fetchVoiceState/fetchPresenceVoiceStateManager(client.voiceStates),PresenceManager(client.presences)voiceStateUpdate,presenceUpdateType of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.