-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(structures): add guild and related structures #11394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
There was a problem hiding this 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
📒 Files selected for processing (22)
packages/structures/src/bitfields/GuildMemberFlagsBitField.tspackages/structures/src/bitfields/GuildSystemChannelFlagsBitField.tspackages/structures/src/bitfields/index.tspackages/structures/src/guild/Ban.tspackages/structures/src/guild/Guild.tspackages/structures/src/guild/GuildIntegration.tspackages/structures/src/guild/GuildMember.tspackages/structures/src/guild/GuildPreview.tspackages/structures/src/guild/GuildTemplate.tspackages/structures/src/guild/GuildWelcomeScreen.tspackages/structures/src/guild/GuildWelcomeScreenChannel.tspackages/structures/src/guild/GuildWidget.tspackages/structures/src/guild/IncidentsData.tspackages/structures/src/guild/IntegrationAccount.tspackages/structures/src/guild/index.tspackages/structures/src/guild/scheduled-event/GuildScheduledEvent.tspackages/structures/src/guild/scheduled-event/GuildScheduledEventEntityMetadata.tspackages/structures/src/guild/scheduled-event/GuildScheduledEventRecurrenceRule.tspackages/structures/src/guild/scheduled-event/GuildScheduledEventRecurrenceRuleNWeekday.tspackages/structures/src/guild/scheduled-event/index.tspackages/structures/src/index.tspackages/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.tspackages/structures/src/bitfields/GuildMemberFlagsBitField.tspackages/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
kXxxnaming convention, and useSymbol.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
Banclass follows the established structure pattern with appropriate generics, and correctly documents that theUsersubstructure should be instantiated by extending classes. Thereasongetter properly accesses the underlying data.packages/structures/src/guild/GuildWelcomeScreen.ts (1)
1-29: LGTM!The
GuildWelcomeScreenclass appropriately exposes only thedescriptionproperty and delegates thewelcome_channelsarray handling to extending classes as documented. This is consistent with the pattern used inBanfor substructure handling.packages/structures/src/guild/scheduled-event/GuildScheduledEventEntityMetadata.ts (1)
11-27: LGTM!The class structure and
locationgetter follow the established patterns correctly.packages/structures/src/guild/GuildWidget.ts (1)
51-64: LGTM!The
createdTimestampandcreatedAtcomputed getters correctly handle the case whereidmay be omitted using theisIdSettype guard, and properly derive the timestamp from the snowflake ID usingDiscordSnowflake.timestampFrom.packages/structures/src/guild/GuildWelcomeScreenChannel.ts (1)
1-49: LGTM!The
GuildWelcomeScreenChannelclass correctly exposes all properties fromAPIGuildWelcomeScreenChannelwith appropriate camelCase naming transformations (channel_id→channelId,emoji_id→emojiId,emoji_name→emojiName). 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
createdTimestampderivation from the guild ID (which is a valid Discord snowflake) is correct, and the documentation clearly explains the intentional omission ofemojis,features, andstickers.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/createdAtpattern correctly uses the integration's snowflake ID.
144-164: LGTM!The
optimizeDataandtoJSONimplementations correctly handle thesynced_attimestamp 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.,
usageCountforusage_count,sourceGuildIdforsource_guild_id).
93-121: LGTM!The
optimizeDataandtoJSONimplementations correctly handle the timestamp parsing and serialization cycle for bothcreated_atandupdated_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.
packages/structures/src/bitfields/GuildSystemChannelFlagsBitField.ts
Outdated
Show resolved
Hide resolved
packages/structures/src/guild/scheduled-event/GuildScheduledEventEntityMetadata.ts
Show resolved
Hide resolved
packages/structures/src/guild/scheduled-event/GuildScheduledEvent.ts
Outdated
Show resolved
Hide resolved
packages/structures/src/guild/scheduled-event/GuildScheduledEvent.ts
Outdated
Show resolved
Hide resolved
packages/structures/src/guild/scheduled-event/GuildScheduledEventRecurrenceRuleNWeekday.ts
Outdated
Show resolved
Hide resolved
packages/structures/src/guild/scheduled-event/GuildScheduledEventRecurrenceRule.ts
Outdated
Show resolved
Hide resolved
packages/structures/src/guild/scheduled-event/GuildScheduledEvent.ts
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This will add all
Guild-related API structures.As of this first post, only the
Guildstructure, and its necessary substructures,GuildWelcomeScreenandGuildIncidentsDatahave been created.Mentioning #10981 for visibility.