From 23a0b6ccf27410963bd4f5c53d9ee2ce019e90a8 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Sun, 21 Aug 2022 10:28:31 +0100 Subject: [PATCH] fix(Guild): Widget channel types and fixes (#8530) fix: various widget fixes Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/structures/Guild.js | 10 +++++++--- packages/discord.js/typings/index.d.ts | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index 6d54fdca61e1..7796f87c7ddf 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -216,6 +216,8 @@ class Guild extends AnonymousGuild { * @type {?boolean} */ this.widgetEnabled = data.widget_enabled; + } else { + this.widgetEnabled ??= null; } if ('widget_channel_id' in data) { @@ -224,6 +226,8 @@ class Guild extends AnonymousGuild { * @type {?string} */ this.widgetChannelId = data.widget_channel_id; + } else { + this.widgetChannelId ??= null; } if ('explicit_content_filter' in data) { @@ -489,7 +493,7 @@ class Guild extends AnonymousGuild { /** * Widget channel for this guild - * @type {?TextChannel} + * @type {?(TextChannel|NewsChannel|VoiceChannel|StageChannel)} * @readonly */ get widgetChannel() { @@ -656,14 +660,14 @@ class Guild extends AnonymousGuild { * Data for the Guild Widget Settings object * @typedef {Object} GuildWidgetSettings * @property {boolean} enabled Whether the widget is enabled - * @property {?GuildChannel} channel The widget invite channel + * @property {?(TextChannel|NewsChannel|VoiceChannel|StageChannel)} channel The widget invite channel */ /** * The Guild Widget Settings object * @typedef {Object} GuildWidgetSettingsData * @property {boolean} enabled Whether the widget is enabled - * @property {?GuildChannelResolvable} channel The widget invite channel + * @property {?(TextChannel|NewsChannel|VoiceChannel|StageChannel|Snowflake)} channel The widget invite channel */ /** diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 61e6935a78a9..b62f3887062b 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1127,7 +1127,7 @@ export class Guild extends AnonymousGuild { public vanityURLUses: number | null; public get voiceAdapterCreator(): InternalDiscordGatewayAdapterCreator; public voiceStates: VoiceStateManager; - public get widgetChannel(): TextChannel | null; + public get widgetChannel(): TextChannel | NewsChannel | VoiceBasedChannel | null; public widgetChannelId: Snowflake | null; public widgetEnabled: boolean | null; public get maximumBitrate(): number; @@ -4830,7 +4830,7 @@ export interface GuildCreateOptions { export interface GuildWidgetSettings { enabled: boolean; - channel: NonThreadGuildBasedChannel | null; + channel: TextChannel | NewsChannel | VoiceBasedChannel | null; } export interface GuildEditData { @@ -4908,7 +4908,7 @@ export interface GuildPruneMembersOptions { export interface GuildWidgetSettingsData { enabled: boolean; - channel: GuildChannelResolvable | null; + channel: TextChannel | NewsChannel | VoiceBasedChannel | Snowflake | null; } export interface GuildSearchMembersOptions {