From 1d4cdee321ab25bb0f109d55a000582825dd79f9 Mon Sep 17 00:00:00 2001 From: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> Date: Sun, 11 Sep 2022 13:29:28 -0500 Subject: [PATCH] types(GuildChannelManager): correct `fetch` return type (#8549) * types(GuildChannelManager): correct `fetch` return type * fix(ci): fix the types tests * fix: fix the docs * Update packages/discord.js/src/managers/GuildChannelManager.js Co-authored-by: Almeida * types: allow channels in the collection to be null Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> * style: run prettier Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> * test: fix types again Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> * style: run prettier Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> Co-authored-by: Almeida Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/managers/GuildChannelManager.js | 2 +- packages/discord.js/typings/index.d.ts | 7 +++++-- packages/discord.js/typings/index.test-d.ts | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/discord.js/src/managers/GuildChannelManager.js b/packages/discord.js/src/managers/GuildChannelManager.js index 012821cfcd76..7e76d5bc89b5 100644 --- a/packages/discord.js/src/managers/GuildChannelManager.js +++ b/packages/discord.js/src/managers/GuildChannelManager.js @@ -317,7 +317,7 @@ class GuildChannelManager extends CachedManager { * Obtains one or more guild channels from Discord, or the channel cache if they're already available. * @param {Snowflake} [id] The channel's id * @param {BaseFetchOptions} [options] Additional options for this fetch - * @returns {Promise>} + * @returns {Promise>} * @example * // Fetch all channels from the guild (excluding threads) * message.guild.channels.fetch() diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 6b8607b1a84c..5588e75dbc4b 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -3364,8 +3364,11 @@ export class GuildChannelManager extends CachedManager; public createWebhook(options: WebhookCreateOptions): Promise; public edit(channel: GuildChannelResolvable, data: GuildChannelEditOptions): Promise; - public fetch(id: Snowflake, options?: BaseFetchOptions): Promise; - public fetch(id?: undefined, options?: BaseFetchOptions): Promise>; + public fetch(id: Snowflake, options?: BaseFetchOptions): Promise; + public fetch( + id?: undefined, + options?: BaseFetchOptions, + ): Promise>; public fetchWebhooks(channel: GuildChannelResolvable): Promise>; public setPosition( channel: GuildChannelResolvable, diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 3a027d871a09..c70dfb5223db 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -1187,9 +1187,9 @@ declare const guildChannelManager: GuildChannelManager; expectType>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildNews })); expectType>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildStageVoice })); - expectType>>(guildChannelManager.fetch()); - expectType>>(guildChannelManager.fetch(undefined, {})); - expectType>(guildChannelManager.fetch('0')); + expectType>>(guildChannelManager.fetch()); + expectType>>(guildChannelManager.fetch(undefined, {})); + expectType>(guildChannelManager.fetch('0')); const channel = guildChannelManager.cache.first()!;