From 32cdaff7eb29cb60a721ee5967875ec64bef0e8a Mon Sep 17 00:00:00 2001 From: Jaworek Date: Fri, 17 Feb 2023 22:25:32 +0100 Subject: [PATCH] feat(Webhook): add `channel` getter (#9074) * fix: add channel property * fix: missing new line --- src/structures/Webhook.js | 11 ++++++++++- typings/index.d.ts | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index d1b3144d8..efb70ced4 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -72,7 +72,7 @@ class Webhook { if ('channel_id' in data) { /** - * The channel the webhook belongs to + * The id of the channel the webhook belongs to * @type {Snowflake} */ this.channelId = data.channel_id; @@ -376,6 +376,15 @@ class Webhook { }); } + /** + * The channel the webhook belongs to + * @type {?(TextChannel|VoiceChannel|NewsChannel|ForumChannel)} + * @readonly + */ + get channel() { + return this.client.channels.resolve(this.channelId); + } + /** * The timestamp the webhook was created at * @type {number} diff --git a/typings/index.d.ts b/typings/index.d.ts index b5efb6b13..4911d2551 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2828,6 +2828,7 @@ export class Webhook extends WebhookMixin() { private constructor(client: Client, data?: RawWebhookData); public avatar: string; public avatarURL(options?: StaticImageURLOptions): string | null; + public readonly channel: TextChannel | VoiceChannel | NewsChannel | ForumChannel | null; public channelId: Snowflake; public client: Client; public guildId: Snowflake;