Skip to content

Conversation

@keston-dev
Copy link

This will add all Guild-related API structures.

As of this first post, only the Guild structure, and its necessary substructures, GuildWelcomeScreen and GuildIncidentsData have been created.

Mentioning #10981 for visibility.

@vercel
Copy link

vercel bot commented Jan 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
discord-js Skipped Skipped Jan 30, 2026 1:19am
discord-js-guide Skipped Skipped Jan 30, 2026 1:19am

Request Review

@vercel vercel bot temporarily deployed to Preview – discord-js January 23, 2026 15:25 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 23, 2026 15:25 Inactive
@keston-dev keston-dev changed the title Feat/guild structure feat(structures): add guild structure Jan 23, 2026
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 23, 2026 19:07 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 23, 2026 19:07 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 23, 2026 19:13 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 23, 2026 19:13 Inactive
@keston-dev keston-dev changed the title feat(structures): add guild structure feat(structures): add guild and related structures Jan 23, 2026
@vercel vercel bot temporarily deployed to Preview – discord-js January 24, 2026 03:53 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 24, 2026 03:53 Inactive
@keston-dev
Copy link
Author

keston-dev commented Jan 24, 2026

To add a quick progress update (based on #10981):

  • Guild:
    • Guild
    • Guild Preview
    • Guild Widget
    • Guild Member
    • Integration
    • Guild Ban
    • Member screening (undocumented)
  • Guild Scheduled Events (As of 6bf4888)
  • Guild Template (As of 6bf4888)

@vercel vercel bot temporarily deployed to Preview – discord-js January 24, 2026 05:44 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 24, 2026 05:44 Inactive
@keston-dev keston-dev marked this pull request as ready for review January 24, 2026 21:49
@keston-dev keston-dev requested a review from a team as a code owner January 24, 2026 21:49
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🤖 Fix all issues with AI agents
In `@packages/structures/src/bitfields/GuildSystemChannelFlagsBitField.ts`:
- Around line 1-2: Import specifier for BitField in
GuildSystemChannelFlagsBitField.ts is inconsistent; change the import from
"import { BitField } from './BitField';" to use the ESM-style "./BitField.js"
specifier to match other bitfield files (e.g., AttachmentFlagsBitField.ts,
ChannelFlagsBitField.ts) and maintain consistency for the BitField symbol used
in this module.

In `@packages/structures/src/guild/Guild.ts`:
- Around line 184-188: The getter systemChannelFlags currently returns null when
this[kData].system_channel_flags is 0 because it uses a truthy check; change the
condition to explicitly check for null/undefined (e.g.,
this[kData].system_channel_flags == null) so that a valid 0 value still
constructs and returns a GuildSystemChannelFlagsBitField using the stored value
(cast as GuildSystemChannelFlags); update the return path in the
systemChannelFlags getter accordingly.

In `@packages/structures/src/guild/GuildIntegration.ts`:
- Line 30: Add public accessor getters for the parsed synced timestamp stored in
the private kSyncedAt field: implement a syncedAtTimestamp getter that returns
the numeric timestamp (number | null) and a syncedAt getter that returns a Date
or null (new Date(timestamp) when timestamp !== null), placed after the revoked
getter to match other structures; ensure to reference the internal symbol
kSyncedAt and update any typing/exports as needed so consumers can read the
timestamp consistent with the existing toJSON serialization.

In `@packages/structures/src/guild/GuildPreview.ts`:
- Line 15: The GuildPreview class declaration is missing a default for the
Omitted generic; update the generic on GuildPreview (the class named
GuildPreview and its type parameter Omitted) to supply the same default used by
other structures (e.g., IntegrationAccount, GuildIntegration) — set Omitted's
default to "keyof APIGuildPreview | ''" so consumers don't have to specify the
type parameter explicitly.

In `@packages/structures/src/guild/GuildTemplate.ts`:
- Around line 28-30: Add public getters for the parsed timestamps so consumers
can read the symbol-backed fields on GuildTemplate: implement createdAt() and
updatedAt() getters (named createdAt and updatedAt) that return the stored
values from the protected symbol fields kCreatedAt and kUpdatedAt (matching the
field types) and place them after the isDirty member; ensure they align with the
class's toJSON serialization so external callers can access the template
timestamps.

In `@packages/structures/src/guild/GuildWidget.ts`:
- Around line 15-21: The GuildWidget generic declaration is missing the default
for the Omitted type parameter; update the class declaration of GuildWidget to
set the Omitted generic default to '' (matching other structures like Ban and
GuildWelcomeScreen) so consumers need not always pass the type argument; ensure
the signature remains GuildWidget<Omitted extends keyof APIGuildWidget | ''>
with the default applied to Omitted and that it still extends
Structure<APIGuildWidget, Omitted>.

In `@packages/structures/src/guild/IncidentsData.ts`:
- Around line 32-94: The incident timestamps are write-only because the parsed
values are stored in symbol properties (kDmSpamDetectedAt, kDmsDisabledUntil,
kInvitesDisabledUntil, kRaidDetectedAt) but no accessors exist; add public
getters on the IncidentsData class to expose both the raw timestamp (number |
null) and a Date variant (Date | null) for each incident (e.g.,
getDmSpamDetectedAt(): number | null and getDmSpamDetectedAtDate(): Date | null
or single getters dmSpamDetectedAt and dmSpamDetectedAtDate), ensuring they read
the symbol fields populated by optimizeData and remain consistent with toJSON
output.

In `@packages/structures/src/guild/IntegrationAccount.ts`:
- Around line 38-51: The IntegrationAccount class exposes createdTimestamp and
createdAt getters that call DiscordSnowflake.timestampFrom and isIdSet on
IntegrationAccount.id, but APIIntegrationAccount.id is not a Discord snowflake
so those getters are invalid; remove the createdTimestamp and createdAt getters
from IntegrationAccount and delete the now-unused imports DiscordSnowflake and
isIdSet (and any related references) so the class no longer attempts to derive
timestamps from the external account id.

In `@packages/structures/src/guild/scheduled-event/GuildScheduledEvent.ts`:
- Around line 29-142: The class GuildScheduledEvent stores scheduled start/end
times in the private symbols kScheduledStartTime and kScheduledEndTime but
exposes no public accessors; add four getters patterned like
createdTimestamp/createdAt: scheduledStartTimestamp (returns kScheduledStartTime
or null), scheduledStartAt (returns Date or null using new Date(timestamp)),
scheduledEndTimestamp, and scheduledEndAt; implement them as public get methods
on GuildScheduledEvent so consumers can read the stored values (use the same
null-checking convention as createdTimestamp/createdAt and reference the
kScheduledStartTime/kScheduledEndTime symbols).

In
`@packages/structures/src/guild/scheduled-event/GuildScheduledEventEntityMetadata.ts`:
- Around line 6-10: Update the JSDoc comment for
GuildScheduledEventEntityMetadata by correcting the typo "addition" to
"additional" in the first sentence so it reads "Represents the additional entity
metadata of a scheduled event on Discord."; locate the docblock above the
GuildScheduledEventEntityMetadata declaration and replace the misspelled word
only, leaving the rest of the JSDoc and `@typeParam` unchanged.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 838cd2d and 6bf4888.

📒 Files selected for processing (22)
  • packages/structures/src/bitfields/GuildMemberFlagsBitField.ts
  • packages/structures/src/bitfields/GuildSystemChannelFlagsBitField.ts
  • packages/structures/src/bitfields/index.ts
  • packages/structures/src/guild/Ban.ts
  • packages/structures/src/guild/Guild.ts
  • packages/structures/src/guild/GuildIntegration.ts
  • packages/structures/src/guild/GuildMember.ts
  • packages/structures/src/guild/GuildPreview.ts
  • packages/structures/src/guild/GuildTemplate.ts
  • packages/structures/src/guild/GuildWelcomeScreen.ts
  • packages/structures/src/guild/GuildWelcomeScreenChannel.ts
  • packages/structures/src/guild/GuildWidget.ts
  • packages/structures/src/guild/IncidentsData.ts
  • packages/structures/src/guild/IntegrationAccount.ts
  • packages/structures/src/guild/index.ts
  • packages/structures/src/guild/scheduled-event/GuildScheduledEvent.ts
  • packages/structures/src/guild/scheduled-event/GuildScheduledEventEntityMetadata.ts
  • packages/structures/src/guild/scheduled-event/GuildScheduledEventRecurrenceRule.ts
  • packages/structures/src/guild/scheduled-event/GuildScheduledEventRecurrenceRuleNWeekday.ts
  • packages/structures/src/guild/scheduled-event/index.ts
  • packages/structures/src/index.ts
  • packages/structures/src/utils/symbols.ts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-24T21:41:15.330Z
Learnt from: Qjuh
Repo: discordjs/discord.js PR: 11393
File: packages/structures/src/bitfields/ApplicationFlagsBitField.ts:13-15
Timestamp: 2026-01-24T21:41:15.330Z
Learning: For BitField classes, preserve numeric flags by using super.toJSON(true) when you need a numeric value. The toJSON(asNumber?: boolean) method returns a number when asNumber is true and a string otherwise, so always pass true to obtain a numeric representation for storage/comparison. This guidance applies to similar bitfield classes across the codebase (not just ApplicationFlagsBitField).

Applied to files:

  • packages/structures/src/bitfields/GuildSystemChannelFlagsBitField.ts
  • packages/structures/src/bitfields/GuildMemberFlagsBitField.ts
  • packages/structures/src/bitfields/index.ts
🧬 Code graph analysis (9)
packages/structures/src/bitfields/GuildSystemChannelFlagsBitField.ts (1)
packages/discord.js/typings/index.d.ts (1)
  • BitField (663-680)
packages/structures/src/bitfields/GuildMemberFlagsBitField.ts (1)
packages/discord.js/typings/index.d.ts (2)
  • BitField (663-680)
  • GuildMemberFlagsBitField (1625-1628)
packages/structures/src/guild/GuildWelcomeScreenChannel.ts (1)
packages/structures/src/utils/symbols.ts (1)
  • kData (1-1)
packages/structures/src/guild/scheduled-event/GuildScheduledEvent.ts (3)
packages/structures/src/utils/symbols.ts (3)
  • kScheduledEndTime (27-27)
  • kScheduledStartTime (28-28)
  • kData (1-1)
packages/structures/src/utils/type-guards.ts (1)
  • isIdSet (1-3)
packages/structures/src/utils/optimization.ts (1)
  • dateToDiscordISOTimestamp (20-22)
packages/structures/src/guild/scheduled-event/GuildScheduledEventEntityMetadata.ts (1)
packages/structures/src/utils/symbols.ts (1)
  • kData (1-1)
packages/structures/src/guild/GuildWelcomeScreen.ts (1)
packages/structures/src/utils/symbols.ts (1)
  • kData (1-1)
packages/structures/src/guild/scheduled-event/GuildScheduledEventRecurrenceRuleNWeekday.ts (1)
packages/structures/src/utils/symbols.ts (1)
  • kData (1-1)
packages/structures/src/guild/IntegrationAccount.ts (7)
packages/structures/src/utils/symbols.ts (1)
  • kData (1-1)
packages/structures/src/utils/type-guards.ts (1)
  • isIdSet (1-3)
packages/discord.js/typings/index.d.ts (1)
  • DiscordSnowflake (3267-3267)
packages/structures/src/guild/Guild.ts (1)
  • createdTimestamp (321-323)
packages/structures/src/guild/GuildIntegration.ts (1)
  • createdTimestamp (129-131)
packages/structures/src/guild/GuildPreview.ts (1)
  • createdTimestamp (88-90)
packages/structures/src/guild/GuildWidget.ts (1)
  • createdTimestamp (54-56)
packages/structures/src/guild/GuildMember.ts (3)
packages/structures/src/utils/symbols.ts (4)
  • kCommunicationDisabledUntil (19-19)
  • kJoinedAt (18-18)
  • kPremiumSince (20-20)
  • kData (1-1)
packages/structures/src/bitfields/GuildMemberFlagsBitField.ts (1)
  • GuildMemberFlagsBitField (7-16)
packages/structures/src/utils/optimization.ts (1)
  • dateToDiscordISOTimestamp (20-22)
🔇 Additional comments (27)
packages/structures/src/utils/symbols.ts (1)

13-31: LGTM!

The new symbol constants are well-organized, follow the established kXxx naming convention, and use Symbol.for() consistently with existing symbols. The logical groupings (incidents data, member data, sync/template timestamps, scheduled events) align with their usage in the corresponding structure classes.

packages/structures/src/guild/Ban.ts (1)

1-26: LGTM!

The Ban class follows the established structure pattern with appropriate generics, and correctly documents that the User substructure should be instantiated by extending classes. The reason getter properly accesses the underlying data.

packages/structures/src/guild/GuildWelcomeScreen.ts (1)

1-29: LGTM!

The GuildWelcomeScreen class appropriately exposes only the description property and delegates the welcome_channels array handling to extending classes as documented. This is consistent with the pattern used in Ban for substructure handling.

packages/structures/src/guild/scheduled-event/GuildScheduledEventEntityMetadata.ts (1)

11-27: LGTM!

The class structure and location getter follow the established patterns correctly.

packages/structures/src/guild/GuildWidget.ts (1)

51-64: LGTM!

The createdTimestamp and createdAt computed getters correctly handle the case where id may be omitted using the isIdSet type guard, and properly derive the timestamp from the snowflake ID using DiscordSnowflake.timestampFrom.

packages/structures/src/guild/GuildWelcomeScreenChannel.ts (1)

1-49: LGTM!

The GuildWelcomeScreenChannel class correctly exposes all properties from APIGuildWelcomeScreenChannel with appropriate camelCase naming transformations (channel_idchannelId, emoji_idemojiId, emoji_nameemojiName). The structure follows established patterns consistently.

packages/structures/src/guild/GuildPreview.ts (1)

23-98: LGTM!

The getters follow the established patterns used in other guild structures. The createdTimestamp derivation from the guild ID (which is a valid Discord snowflake) is correct, and the documentation clearly explains the intentional omission of emojis, features, and stickers.

packages/structures/src/guild/GuildIntegration.ts (2)

40-139: LGTM!

The getters are well-documented with clear notes about fields not provided for Discord bot integrations. The createdTimestamp/createdAt pattern correctly uses the integration's snowflake ID.


144-164: LGTM!

The optimizeData and toJSON implementations correctly handle the synced_at timestamp parsing and serialization cycle.

packages/structures/src/guild/GuildTemplate.ts (2)

41-88: LGTM!

The property getters are clean and follow the established naming conventions (e.g., usageCount for usage_count, sourceGuildId for source_guild_id).


93-121: LGTM!

The optimizeData and toJSON implementations correctly handle the timestamp parsing and serialization cycle for both created_at and updated_at.

packages/structures/src/index.ts (1)

5-5: LGTM!

The guild barrel export is correctly placed in alphabetical order and follows the existing re-export pattern.

packages/structures/src/bitfields/index.ts (1)

5-6: LGTM!

The new bitfield exports are correctly placed in alphabetical order within the barrel file.

packages/structures/src/guild/scheduled-event/index.ts (1)

1-4: Barrel exports look good.
Clean central entry point for scheduled-event structures.

packages/structures/src/guild/scheduled-event/GuildScheduledEventRecurrenceRuleNWeekday.ts (1)

13-35: LGTM — accessors are straightforward.

packages/structures/src/bitfields/GuildMemberFlagsBitField.ts (1)

7-15: LGTM — BitField wrapper is consistent.

packages/structures/src/guild/GuildMember.ts (3)

29-47: DataTemplate + cache wiring looks solid.
Clean separation of raw data and cached timestamps.


49-92: Accessor set is consistent and clear.
Simple, predictable passthroughs plus a typed flags wrapper.


94-133: Timestamp normalization/serialization is well‑handled.
The parse/cache/serialize flow is consistent with the structure pattern.

packages/structures/src/guild/scheduled-event/GuildScheduledEventRecurrenceRule.ts (3)

25-40: Template + caching setup is consistent with other structures.


42-90: Getter surface looks good.
Mapped fields are direct and readable.


95-123: Serialization round‑trip is correct and tidy.

packages/structures/src/guild/index.ts (1)

1-12: Barrel exports are complete and coherent.

packages/structures/src/guild/Guild.ts (4)

21-23: Constructor is minimal and correct.


25-176: Field accessors are straightforward and consistent.


191-316: Remaining accessors follow the expected mapping.


318-331: createdTimestamp/createdAt derivation is clean.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@vercel vercel bot temporarily deployed to Preview – discord-js January 24, 2026 21:58 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 24, 2026 21:58 Inactive
@keston-dev keston-dev marked this pull request as draft January 24, 2026 22:02
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 24, 2026 22:33 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 24, 2026 22:33 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 24, 2026 22:36 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 24, 2026 22:36 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 24, 2026 23:49 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 24, 2026 23:49 Inactive
@keston-dev keston-dev marked this pull request as ready for review January 25, 2026 02:44
@github-project-automation github-project-automation bot moved this from Todo to Review in Progress in discord.js Jan 25, 2026
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 25, 2026 19:05 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 25, 2026 19:05 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 30, 2026 01:11 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 30, 2026 01:11 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 30, 2026 01:14 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 30, 2026 01:14 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 30, 2026 01:19 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 30, 2026 01:19 Inactive
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 2.81426% with 518 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.55%. Comparing base (c71228a) to head (e682914).

Files with missing lines Patch % Lines
packages/structures/src/guild/Guild.ts 0.00% 103 Missing ⚠️
packages/structures/src/guild/GuildMember.ts 0.00% 65 Missing ⚠️
...s/src/guild/scheduled-event/GuildScheduledEvent.ts 0.00% 63 Missing ⚠️
packages/structures/src/guild/IncidentsData.ts 0.00% 56 Missing ⚠️
packages/structures/src/guild/GuildIntegration.ts 0.00% 47 Missing ⚠️
packages/structures/src/guild/GuildTemplate.ts 0.00% 46 Missing ⚠️
...heduled-event/GuildScheduledEventRecurrenceRule.ts 0.00% 46 Missing ⚠️
packages/structures/src/guild/GuildPreview.ts 0.00% 30 Missing ⚠️
packages/structures/src/guild/GuildWidget.ts 0.00% 16 Missing ⚠️
.../structures/src/guild/GuildWelcomeScreenChannel.ts 0.00% 11 Missing ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11394      +/-   ##
==========================================
- Coverage   31.62%   30.55%   -1.07%     
==========================================
  Files         385      402      +17     
  Lines       13918    14451     +533     
  Branches     1096     1163      +67     
==========================================
+ Hits         4401     4416      +15     
- Misses       9383     9901     +518     
  Partials      134      134              
Flag Coverage Δ
structures 26.73% <2.81%> (-8.94%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Review in Progress

Development

Successfully merging this pull request may close these issues.

2 participants