From a8e60105fb18b8a3de064898db76560907f12a67 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Sun, 3 Oct 2021 14:01:38 +0100 Subject: [PATCH] types: More accurate types instead of `GuildChannelResolvable` (#6744) --- src/managers/GuildInviteManager.js | 17 +++++++++++++++-- src/structures/NewsChannel.js | 2 +- typings/index.d.ts | 14 +++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/managers/GuildInviteManager.js b/src/managers/GuildInviteManager.js index 2e5d2babd..c229a5810 100644 --- a/src/managers/GuildInviteManager.js +++ b/src/managers/GuildInviteManager.js @@ -38,6 +38,18 @@ class GuildInviteManager extends CachedManager { * @typedef {string} InviteResolvable */ + /** + * Data that can be resolved to a channel that an invite can be created on. This can be: + * * TextChannel + * * VoiceChannel + * * NewsChannel + * * StoreChannel + * * StageChannel + * * Snowflake + * @typedef {TextChannel|VoiceChannel|NewsChannel|StoreChannel|StageChannel|Snowflake} + * GuildInvitableChannelResolvable + */ + /** * Resolves an InviteResolvable to an Invite object. * @method resolve @@ -67,7 +79,8 @@ class GuildInviteManager extends CachedManager { /** * Options used to fetch all invites from a guild. * @typedef {Object} FetchInvitesOptions - * @property {GuildChannelResolvable} [channelId] The channel to fetch all invites from + * @property {GuildInvitableChannelResolvable} [channelId] + * The channel to fetch all invites from * @property {boolean} [cache=true] Whether or not to cache the fetched invites */ @@ -153,7 +166,7 @@ class GuildInviteManager extends CachedManager { /** * Create an invite to the guild from the provided channel. - * @param {GuildChannelResolvable} channel The options for creating the invite from a channel. + * @param {GuildInvitableChannelResolvable} channel The options for creating the invite from a channel. * @param {CreateInviteOptions} [options={}] The options for creating the invite from a channel. * @returns {Promise} * @example diff --git a/src/structures/NewsChannel.js b/src/structures/NewsChannel.js index b5d6f2fc3..e2ef0a87c 100644 --- a/src/structures/NewsChannel.js +++ b/src/structures/NewsChannel.js @@ -10,7 +10,7 @@ const { Error } = require('../errors'); class NewsChannel extends BaseGuildTextChannel { /** * Adds the target to this channel's followers. - * @param {GuildChannelResolvable} channel The channel where the webhook should be created + * @param {TextChannelResolvable} channel The channel where the webhook should be created * @param {string} [reason] Reason for creating the webhook * @returns {Promise} * @example diff --git a/typings/index.d.ts b/typings/index.d.ts index 27ad42da4..b43171b58 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1524,7 +1524,7 @@ export class MessageSelectMenu extends BaseMessageComponent { export class NewsChannel extends BaseGuildTextChannel { public threads: ThreadManager; public type: 'GUILD_NEWS'; - public addFollower(channel: GuildChannelResolvable, reason?: string): Promise; + public addFollower(channel: TextChannelResolvable, reason?: string): Promise; } export class OAuth2Guild extends BaseGuild { @@ -2664,7 +2664,7 @@ export class GuildBanManager extends CachedManager { public constructor(guild: Guild, iterable?: Iterable); public guild: Guild; - public create(channel: GuildChannelResolvable, options?: CreateInviteOptions): Promise; + public create(channel: GuildInvitableChannelResolvable, options?: CreateInviteOptions): Promise; public fetch(options: InviteResolvable | FetchInviteOptions): Promise; public fetch(options?: FetchInvitesOptions): Promise>; public delete(invite: InviteResolvable, reason?: string): Promise; @@ -3836,7 +3836,7 @@ interface FetchInviteOptions extends BaseFetchOptions { } interface FetchInvitesOptions { - channelId?: GuildChannelResolvable; + channelId?: GuildInvitableChannelResolvable; cache?: boolean; } @@ -4222,6 +4222,14 @@ export interface InviteGenerationOptions { scopes: InviteScope[]; } +type GuildInvitableChannelResolvable = + | TextChannel + | VoiceChannel + | NewsChannel + | StoreChannel + | StageChannel + | Snowflake; + export interface CreateInviteOptions { temporary?: boolean; maxAge?: number;