Skip to content
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

fix(Guild): Widget channel types and fixes #8530

Merged
merged 2 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/discord.js/src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -489,7 +493,7 @@ class Guild extends AnonymousGuild {

/**
* Widget channel for this guild
* @type {?TextChannel}
* @type {?(TextChannel|NewsChannel|VoiceChannel|StageChannel)}
* @readonly
*/
get widgetChannel() {
Expand Down Expand Up @@ -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
*/

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,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;
Expand Down Expand Up @@ -4825,7 +4825,7 @@ export interface GuildCreateOptions {

export interface GuildWidgetSettings {
enabled: boolean;
channel: NonThreadGuildBasedChannel | null;
channel: TextChannel | NewsChannel | VoiceBasedChannel | null;
}

export interface GuildEditData {
Expand Down Expand Up @@ -4903,7 +4903,7 @@ export interface GuildPruneMembersOptions {

export interface GuildWidgetSettingsData {
enabled: boolean;
channel: GuildChannelResolvable | null;
channel: TextChannel | NewsChannel | VoiceBasedChannel | Snowflake | null;
}

export interface GuildSearchMembersOptions {
Expand Down