From 875c86a4efc52482189ed4c4c44b8a11bb5588fe Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Mon, 31 Jan 2022 16:10:32 +0000 Subject: [PATCH] revert: refactor(invite): make `channel` a getter (#7365) --- packages/discord.js/src/structures/Invite.js | 22 ++++---------------- packages/discord.js/typings/index.d.ts | 3 +-- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/packages/discord.js/src/structures/Invite.js b/packages/discord.js/src/structures/Invite.js index 982d9950b..ffa6b04e1 100644 --- a/packages/discord.js/src/structures/Invite.js +++ b/packages/discord.js/src/structures/Invite.js @@ -151,16 +151,12 @@ class Invite extends Base { this.targetType ??= null; } - if ('channel_id' in data) { + if ('channel' in data) { /** - * The channel's id this invite is for - * @type {?Snowflake} + * The channel this invite is for + * @type {?Channel} */ - this.channelId = data.channel_id; - } - - if (data.channel) { - this.channelId ??= data.channel.id; + this.channel = this.client.channels._add(data.channel, this.guild, { cache: false }); } if ('created_at' in data) { @@ -197,15 +193,6 @@ class Invite extends Base { } } - /** - * The channel this invite is for - * @type {Channel} - * @readonly - */ - get channel() { - return this.client.channels.resolve(this.channelId); - } - /** * The time the invite was created at * @type {?Date} @@ -297,7 +284,6 @@ class Invite extends Base { presenceCount: false, memberCount: false, uses: false, - channel: 'channelId', inviter: 'inviterId', guild: 'guildId', }); diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 2250594d1..a9c77b95e 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1365,8 +1365,7 @@ export class InteractionWebhook extends PartialWebhookMixin() { export class Invite extends Base { private constructor(client: Client, data: RawInviteData); - public readonly channel: NonThreadGuildBasedChannel | PartialGroupDMChannel; - public channelId: Snowflake | null; + public channel: NonThreadGuildBasedChannel | PartialGroupDMChannel; public code: string; public readonly deletable: boolean; public readonly createdAt: Date | null;