From 2397e260ac000f883f4fb7b2f9631efd7d4e94ef Mon Sep 17 00:00:00 2001 From: almeidx Date: Thu, 10 Mar 2022 12:36:46 +0000 Subject: [PATCH 1/2] fix(GuildEditData): some fields can be null for v13 --- src/structures/Guild.js | 10 +++++----- typings/index.d.ts | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index c8471e471eae..04772fdbf9ce 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -810,8 +810,8 @@ class Guild extends AnonymousGuild { * @property {string} [name] The name of the guild * @property {VerificationLevel|number} [verificationLevel] The verification level of the guild * @property {ExplicitContentFilterLevel|number} [explicitContentFilter] The level of the explicit content filter - * @property {VoiceChannelResolvable} [afkChannel] The AFK channel of the guild - * @property {TextChannelResolvable} [systemChannel] The system channel of the guild + * @property {?VoiceChannelResolvable} [afkChannel] The AFK channel of the guild + * @property {?TextChannelResolvable} [systemChannel] The system channel of the guild * @property {number} [afkTimeout] The AFK timeout of the guild * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon of the guild * @property {GuildMemberResolvable} [owner] The owner of the guild @@ -821,11 +821,11 @@ class Guild extends AnonymousGuild { * @property {DefaultMessageNotificationLevel|number} [defaultMessageNotifications] The default message notification * level of the guild * @property {SystemChannelFlagsResolvable} [systemChannelFlags] The system channel flags of the guild - * @property {TextChannelResolvable} [rulesChannel] The rules channel of the guild - * @property {TextChannelResolvable} [publicUpdatesChannel] The community updates channel of the guild + * @property {?TextChannelResolvable} [rulesChannel] The rules channel of the guild + * @property {?TextChannelResolvable} [publicUpdatesChannel] The community updates channel of the guild * @property {string} [preferredLocale] The preferred locale of the guild * @property {boolean} [premiumProgressBarEnabled] Whether the guild's premium progress bar is enabled - * @property {string} [description] The discovery description of the guild + * @property {?string} [description] The discovery description of the guild * @property {Features[]} [features] The features of the guild */ diff --git a/typings/index.d.ts b/typings/index.d.ts index de4e3f486586..956ed506e38b 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -4692,8 +4692,8 @@ export interface GuildEditData { verificationLevel?: VerificationLevel | number; explicitContentFilter?: ExplicitContentFilterLevel | number; defaultMessageNotifications?: DefaultMessageNotificationLevel | number; - afkChannel?: VoiceChannelResolvable; - systemChannel?: TextChannelResolvable; + afkChannel?: VoiceChannelResolvable | null; + systemChannel?: TextChannelResolvable| null; systemChannelFlags?: SystemChannelFlagsResolvable; afkTimeout?: number; icon?: BufferResolvable | Base64Resolvable | null; @@ -4701,8 +4701,8 @@ export interface GuildEditData { splash?: BufferResolvable | Base64Resolvable | null; discoverySplash?: BufferResolvable | Base64Resolvable | null; banner?: BufferResolvable | Base64Resolvable | null; - rulesChannel?: TextChannelResolvable; - publicUpdatesChannel?: TextChannelResolvable; + rulesChannel?: TextChannelResolvable | null; + publicUpdatesChannel?: TextChannelResolvable | null; preferredLocale?: string; premiumProgressBarEnabled?: boolean; description?: string | null; From baca10b471909ee81fb9542d95fe414b4713d9e7 Mon Sep 17 00:00:00 2001 From: almeidx Date: Thu, 10 Mar 2022 17:57:28 +0000 Subject: [PATCH 2/2] fix: make even more things nullable --- src/structures/Guild.js | 28 ++++++++++++++-------------- typings/index.d.ts | 18 +++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 04772fdbf9ce..ff223fde2025 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -808,8 +808,8 @@ class Guild extends AnonymousGuild { * The data for editing a guild. * @typedef {Object} GuildEditData * @property {string} [name] The name of the guild - * @property {VerificationLevel|number} [verificationLevel] The verification level of the guild - * @property {ExplicitContentFilterLevel|number} [explicitContentFilter] The level of the explicit content filter + * @property {?(VerificationLevel|number)} [verificationLevel] The verification level of the guild + * @property {?(ExplicitContentFilterLevel|number)} [explicitContentFilter] The level of the explicit content filter * @property {?VoiceChannelResolvable} [afkChannel] The AFK channel of the guild * @property {?TextChannelResolvable} [systemChannel] The system channel of the guild * @property {number} [afkTimeout] The AFK timeout of the guild @@ -818,12 +818,12 @@ class Guild extends AnonymousGuild { * @property {?(BufferResolvable|Base64Resolvable)} [splash] The invite splash image of the guild * @property {?(BufferResolvable|Base64Resolvable)} [discoverySplash] The discovery splash image of the guild * @property {?(BufferResolvable|Base64Resolvable)} [banner] The banner of the guild - * @property {DefaultMessageNotificationLevel|number} [defaultMessageNotifications] The default message notification - * level of the guild + * @property {?(DefaultMessageNotificationLevel|number)} [defaultMessageNotifications] The default message + * notification level of the guild * @property {SystemChannelFlagsResolvable} [systemChannelFlags] The system channel flags of the guild * @property {?TextChannelResolvable} [rulesChannel] The rules channel of the guild * @property {?TextChannelResolvable} [publicUpdatesChannel] The community updates channel of the guild - * @property {string} [preferredLocale] The preferred locale of the guild + * @property {?string} [preferredLocale] The preferred locale of the guild * @property {boolean} [premiumProgressBarEnabled] Whether the guild's premium progress bar is enabled * @property {?string} [description] The discovery description of the guild * @property {Features[]} [features] The features of the guild @@ -906,7 +906,7 @@ class Guild extends AnonymousGuild { if (typeof data.description !== 'undefined') { _data.description = data.description; } - if (data.preferredLocale) _data.preferred_locale = data.preferredLocale; + if (typeof data.preferredLocale !== 'undefined') _data.preferred_locale = data.preferredLocale; if ('premiumProgressBarEnabled' in data) _data.premium_progress_bar_enabled = data.premiumProgressBarEnabled; const newData = await this.client.api.guilds(this.id).patch({ data: _data, reason }); return this.client.actions.GuildUpdate.handle(newData).updated; @@ -984,7 +984,7 @@ class Guild extends AnonymousGuild { /** * Edits the level of the explicit content filter. - * @param {ExplicitContentFilterLevel|number} explicitContentFilter The new level of the explicit content filter + * @param {?(ExplicitContentFilterLevel|number)} explicitContentFilter The new level of the explicit content filter * @param {string} [reason] Reason for changing the level of the guild's explicit content filter * @returns {Promise} */ @@ -995,7 +995,7 @@ class Guild extends AnonymousGuild { /* eslint-disable max-len */ /** * Edits the setting of the default message notifications of the guild. - * @param {DefaultMessageNotificationLevel|number} defaultMessageNotifications The new default message notification level of the guild + * @param {?(DefaultMessageNotificationLevel|number)} defaultMessageNotifications The new default message notification level of the guild * @param {string} [reason] Reason for changing the setting of the default message notifications * @returns {Promise} */ @@ -1031,7 +1031,7 @@ class Guild extends AnonymousGuild { /** * Edits the verification level of the guild. - * @param {VerificationLevel|number} verificationLevel The new verification level of the guild + * @param {?(VerificationLevel|number)} verificationLevel The new verification level of the guild * @param {string} [reason] Reason for changing the guild's verification level * @returns {Promise} * @example @@ -1046,7 +1046,7 @@ class Guild extends AnonymousGuild { /** * Edits the AFK channel of the guild. - * @param {VoiceChannelResolvable} afkChannel The new AFK channel + * @param {?VoiceChannelResolvable} afkChannel The new AFK channel * @param {string} [reason] Reason for changing the guild's AFK channel * @returns {Promise} * @example @@ -1061,7 +1061,7 @@ class Guild extends AnonymousGuild { /** * Edits the system channel of the guild. - * @param {TextChannelResolvable} systemChannel The new system channel + * @param {?TextChannelResolvable} systemChannel The new system channel * @param {string} [reason] Reason for changing the guild's system channel * @returns {Promise} * @example @@ -1166,7 +1166,7 @@ class Guild extends AnonymousGuild { /** * Edits the rules channel of the guild. - * @param {TextChannelResolvable} rulesChannel The new rules channel + * @param {?TextChannelResolvable} rulesChannel The new rules channel * @param {string} [reason] Reason for changing the guild's rules channel * @returns {Promise} * @example @@ -1181,7 +1181,7 @@ class Guild extends AnonymousGuild { /** * Edits the community updates channel of the guild. - * @param {TextChannelResolvable} publicUpdatesChannel The new community updates channel + * @param {?TextChannelResolvable} publicUpdatesChannel The new community updates channel * @param {string} [reason] Reason for changing the guild's community updates channel * @returns {Promise} * @example @@ -1196,7 +1196,7 @@ class Guild extends AnonymousGuild { /** * Edits the preferred locale of the guild. - * @param {string} preferredLocale The new preferred locale of the guild + * @param {?string} preferredLocale The new preferred locale of the guild * @param {string} [reason] Reason for changing the guild's preferred locale * @returns {Promise} * @example diff --git a/typings/index.d.ts b/typings/index.d.ts index 956ed506e38b..55d1b2240ce2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -954,7 +954,7 @@ export class Guild extends AnonymousGuild { /** @deprecated Use {@link GuildChannelManager.setPositions} instead */ public setChannelPositions(channelPositions: readonly ChannelPosition[]): Promise; public setDefaultMessageNotifications( - defaultMessageNotifications: DefaultMessageNotificationLevel | number, + defaultMessageNotifications: DefaultMessageNotificationLevel | number | null, reason?: string, ): Promise; public setDiscoverySplash( @@ -962,13 +962,13 @@ export class Guild extends AnonymousGuild { reason?: string, ): Promise; public setExplicitContentFilter( - explicitContentFilter: ExplicitContentFilterLevel | number, + explicitContentFilter: ExplicitContentFilterLevel | number | null, reason?: string, ): Promise; public setIcon(icon: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setName(name: string, reason?: string): Promise; public setOwner(owner: GuildMemberResolvable, reason?: string): Promise; - public setPreferredLocale(preferredLocale: string, reason?: string): Promise; + public setPreferredLocale(preferredLocale: string | null, reason?: string): Promise; public setPublicUpdatesChannel(publicUpdatesChannel: TextChannelResolvable | null, reason?: string): Promise; /** @deprecated Use {@link RoleManager.setPositions} instead */ public setRolePositions(rolePositions: readonly RolePosition[]): Promise; @@ -976,7 +976,7 @@ export class Guild extends AnonymousGuild { public setSplash(splash: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setSystemChannel(systemChannel: TextChannelResolvable | null, reason?: string): Promise; public setSystemChannelFlags(systemChannelFlags: SystemChannelFlagsResolvable, reason?: string): Promise; - public setVerificationLevel(verificationLevel: VerificationLevel | number, reason?: string): Promise; + public setVerificationLevel(verificationLevel: VerificationLevel | number | null, reason?: string): Promise; public setPremiumProgressBarEnabled(enabled?: boolean, reason?: string): Promise; public setWidgetSettings(settings: GuildWidgetSettingsData, reason?: string): Promise; public toJSON(): unknown; @@ -4689,11 +4689,11 @@ export interface GuildWidgetSettings { export interface GuildEditData { name?: string; - verificationLevel?: VerificationLevel | number; - explicitContentFilter?: ExplicitContentFilterLevel | number; - defaultMessageNotifications?: DefaultMessageNotificationLevel | number; + verificationLevel?: VerificationLevel | number | null; + explicitContentFilter?: ExplicitContentFilterLevel | number | null; + defaultMessageNotifications?: DefaultMessageNotificationLevel | number | null; afkChannel?: VoiceChannelResolvable | null; - systemChannel?: TextChannelResolvable| null; + systemChannel?: TextChannelResolvable | null; systemChannelFlags?: SystemChannelFlagsResolvable; afkTimeout?: number; icon?: BufferResolvable | Base64Resolvable | null; @@ -4703,7 +4703,7 @@ export interface GuildEditData { banner?: BufferResolvable | Base64Resolvable | null; rulesChannel?: TextChannelResolvable | null; publicUpdatesChannel?: TextChannelResolvable | null; - preferredLocale?: string; + preferredLocale?: string | null; premiumProgressBarEnabled?: boolean; description?: string | null; features?: GuildFeatures[];