Skip to content

feat: bring gateway guilds, emojis, stickers and invites to discord.js parity - #98

Merged
RedStar071 merged 2 commits into
feat/users-members-rolesfrom
feat/guild-assets
Sep 25, 2026
Merged

RedStar071 merged 2 commits into
feat/users-members-rolesfrom
feat/guild-assets

Conversation

@RedStar071

Copy link
Copy Markdown
Member

Stacked on #97.

🔗 Linked issue

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

🧭 Context

Guild only had a dozen getters, and emojis, stickers and invites did not exist at all. A bot could not rename its guild, upload an emoji, or create an invite without raw REST calls. The emoji, sticker and invite events were missing too, so GUILD_EMOJIS_UPDATE only showed up as raw.

📚 Description

Guild now has every field the API returns, and the editing methods discord.js has: the set* family, disableInvites, setIncidentActions, leave and delete. It also gets fetchOwner, fetchPreview, fetchVanityData and fetchVoiceRegions. leave and delete run the same cascade as a GUILD_DELETE, so no channel, member or role of the guild stays in the cache. Emojis, stickers and invites get their structures and guild managers, following discord.js's names. The client gets fetchInvite, fetchSticker, fetchStickerPacks and fetchVoiceRegions.

The part I would look at first is the emoji and sticker events. Discord sends the whole list on every change, and discord.js diffs it against its cache. The dispatch table so far allowed one event per dispatch, so it gains a small MultiDispatchHandlers table whose handlers return a list of events. Two consequences worth knowing:

  • Without a cache there is nothing to diff against, so the six events are simply not emitted and the payload stays on raw. Emitting every emoji as "created" on each update seemed worse than nothing.
  • The previous list is read with listCached(), which enumerates the entity cache's keys. On Redis that reads the whole emoji or sticker index for one guild. It's fine at bot scale, but a per-guild index would be the fix if it ever shows up in profiles.

Invites come in two shapes: REST has nested channel and guild, INVITE_CREATE has flat channel_id and guild_id. The invite structures accept both, and the cache stores the REST ones with the flat IDs added, so inviteDelete finds them either way.

Left out on purpose: Guild#fetchWebhooks (webhooks come with the channel phase), the welcome screen, widget, onboarding, templates, integrations, audit logs, bans list and scheduled events (moderation and admin phase), and discord.js's afkChannel/systemChannel... getters, since the IDs are there and the channel lookup is async.

Key changes

Area Change
Guild All fields, edit/set*, disableInvites, setIncidentActions, leave, delete, fetchOwner/Preview/VanityData/VoiceRegions, equals
AnonymousGuild, InviteGuild, GuildPreview Partial guilds from invites and previews
Emojis Emoji, GuildEmoji, GuildEmojiManager, GuildEmojiRoleManager
Stickers Sticker, StickerPack, GuildStickerManager (multipart upload)
Invites BaseInvite, GuildInvite, GroupDMInvite, createInvite, GuildInviteManager
Events emojiCreate/Update/Delete, stickerCreate/Update/Delete, inviteCreate, inviteDelete

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.

@RedStar071
RedStar071 added this pull request to stack #96 September 24, 2026 16:36

@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 critical issues — minor suggestions inline.

Reviewed changes

  • New discord.js-parity structures for guild assets: AnonymousGuild, BaseInvite/GuildInvite/GroupDMInvite, Emoji/GuildEmoji, Sticker/StickerPack, GuildPreview, InviteGuild.
  • New managers GuildEmojiManager, GuildEmojiRoleManager, GuildStickerManager, GuildInviteManager, plus GuildManager additions (emojis()/stickers()/invites() accessors, create/edit/leave/delete/fetchPreview/fetchVoiceRegions/fetchVanityData/setIncidentActions).
  • GatewayClient additions: fetchInvite, fetchSticker, fetchStickerPacks, fetchVoiceRegions.
  • A new MultiDispatchHandlers mechanism turning GUILD_EMOJIS_UPDATE/GUILD_STICKERS_UPDATE into per-entity create/update/delete events via a cache-diff helper, plus INVITE_CREATE/INVITE_DELETE single-dispatch handlers.
  • Extensive new test coverage (tests/guild-assets.test.ts, 485 lines) for derived fields, CRUD flows, and the multi-dispatch diff logic end-to-end.

ℹ️ Nitpicks

  • GuildManager.forget() (used by leave()/delete()) applies a synthetic GUILD_DELETE straight to the cache, bypassing DispatchQueue's per-guild partition ordering. A real GUILD_DELETE arriving concurrently for the same guild could race with this out-of-band mutation. Low risk in practice — Discord will still deliver a genuine GUILD_DELETE afterwards that re-runs the same cascade through the properly-queued path — but flagging since every other cache mutation in this package goes through the queue. See inline comment.

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

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

@wolfstar/plugin-api

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

@wolfstar/plugin-cache

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

@wolfstar/plugin-gateway

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

@wolfstar/plugin-i18next

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

@wolfstar/plugin-logger

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

@wolfstar/plugin-subcommands-advanced

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

commit: 9307a42

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

…iscord.js parity

Guild gains every field and discord.js's editing methods, and emojis,
stickers, sticker packs and invites get their structures and guild
managers. Emoji and sticker events are diffed against the cache, since
Discord sends the whole list on every change.

Refs #54
@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 3fb3e5d into main Sep 25, 2026
18 of 25 checks passed
@RedStar071
RedStar071 deleted the feat/guild-assets 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