Repository navigation
feat: bring gateway users, members and roles to discord.js parity - #97
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. |
There was a problem hiding this comment.
Important
One correctness issue found: Role#setPosition() returns data that can silently diverge from what's actually cached.
Reviewed changes
Reviewed the full diff (19 files, 1 commit 4989c45): verified every new discord-api-types REST payload shape against the vendored type definitions, ran the new/updated test suites (37/37 pass), and typechecked the package clean.
ClientUser(new): profile edit and presence (setPresence/setStatus/setActivity/setAFK), sent on every shard or a chosen subset.client.useris now typedClientUser | null;USER_UPDATEfor the bot's own ID patches it in place instead of replacing it with a plainUser.GuildMember: full field surface, arolesgetter returning a newGuildMemberRoleManager, asyncfetchPermissions/fetchManageable/fetchKickable/fetchBannable/fetchModeratable,edit/timeout/kick/ban, DM helpers,equals.Role:permissionsis nowReadonly<PermissionsBitField>instead ofbigint(breaking, called out in the changeset asminorsince the package is unreleased), colors/icon/tags/flags,comparePositionTo,edit/set*,setPosition,delete,equals.- Managers:
GuildMemberManagergainslist/search/add/edit/editMe/kick/ban/unban/bulkBan/prune/addRole/removeRole;RoleManagergainsfetchAll/fetchMemberCounts/create/edit/delete/setPosition(s)/everyone/highest/premiumSubscriberRole/botRoleFor;UserManagergainscreateDM/deleteDM/send. util/permissions.ts(new):computeGuildPermissions(owner/admin bypass, else@everyone+ role bits) andcompareRolePositions(position, then ID tiebreak) — checked byte-for-byte equivalent to discord.js's own algorithm.tsconfig.base.json:libmovedES2022→ES2023forArray#toSorted, used throughout the new manager code.
ℹ️ Nitpicks
GuildMemberManager.managedWith()(src/structures/GuildMember.ts) callsfetchManageable()(which already fetches the guild and both members' highest roles) and then separately re-fetches "me" and its permissions — a bit of avoidable round-tripping, not incorrect.GuildPermissionsContext.roles(src/util/permissions.ts) is documented as "Every role of the guild,@everyoneincluded", but every caller only ever passes the member's own roles plus@everyone. The algorithm only needs that subset so it's not a bug, just a doc wording that overstates what's actually passed in.
Claude Sonnet | 𝕏
@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 one new commit (2c7fa7f) since the prior pullfrog review.
- Fixed
Role#setPosition()to keep the API's actual applied position: it now captures theRole[]returned byroles.setPositions(), finds the matching entry by ID, and patchesthisfrom that (this[kPatch](updated.toJSON())) instead of blindly echoing the requestedposition— exactly the fix suggested in the prior review. - Added a regression test: mocks a clamped API response (requested position
99, Discord applies3) and asserts both the returned instance and the cached one land on the actual applied position.
Claude Sonnet | 𝕏
2c7fa7f to
7d9adf9
Compare
7d9adf9 to
020db82
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 →
|
…rity Adds every API field and CDN URL, ClientUser with presence updates, GuildMemberRoleManager, permission computation, member moderation and listing, and role CRUD and positioning. Relations discord.js reads synchronously are async fetch* methods, since the cache can be Redis. Refs #54
020db82 to
55c73f8
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 #95.
🔗 Linked issue
Related to #54 (phase 5 of the roadmap).
🧭 Context
Until now
User,GuildMemberandRolewere thin wrappers exposing a handful of getters. A bot moving from discord.js had no way to add a role, time someone out, check whether it may kick a member, or set its own activity without dropping to raw REST calls. This phase covers what discord.js offers on those three entities and their managers.📚 Description
Every API field is exposed, the CDN helpers (banner, avatar decoration, guild tag badge, role icon) come from
@discordjs/rest, and the REST methods match discord.js's names.The one systematic difference is async relations. discord.js reads
member.permissions,member.kickableormember.roles.highestsynchronously from its in-memory cache. Here the cache can be Redis, so they becomefetchPermissions(),fetchKickable()androles.fetchHighest(). They read the cache first and hit the API on a miss. For permissions, only the member's roles and@everyoneare fetched, not every role of the guild.Other choices worth a look:
client.useris now aClientUser. ItssetPresencesends the update on every shard the gateway manages, or on the ones passed. The bot's ownUSER_UPDATEpatches it in place instead of swapping it for a plainUser.createDMalways calls the API. Discord returns the existing channel when there is one, and without a sync cache there is nothing cheap to check first, so discord.js'sforceoption has no equivalent.Role#permissionsis aPermissionsBitFieldinstead of abigint. It's a breaking change on an unreleased package, called out in the changeset asminor.ban,bulkBanandpruneare in, since discord.js has them onGuildMemberManager. The ban list itself (GuildBanManager) stays in the later moderation phase.tsconfig.base.jsonmoveslibto ES2023 fortoSorted, which every Node version the packages support has.Not ported, deliberately:
member.voiceandmember.presence(phase 10),permissionsIn(channel)(phase 8, it needs overwrites), andRole#members, which would need every member of the guild.Key changes
Usertag, banner/decoration/badge URLs,createDM/deleteDM/send,fetch,equalsClientUseredit/setUsername/setAvatar/setBanner,setPresence/setStatus/setActivity/setAFKGuildMemberroles,fetchPermissions,fetchManageable/Kickable/Bannable/Moderatable,edit,timeout,kick,ban, DM helpersRolePermissionsBitField, colors, icon, tags, flags,comparePositionTo,edit/set*,setPosition,deleteGuildMemberRoleManager(new),GuildMemberManagerlist/search/add/edit/kick/ban/prune,RoleManagerCRUD/positions/member counts,UserManagerDMsType of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.