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

types(GuildChannelManager): correct fetch return type #8549

Merged
merged 12 commits into from Sep 11, 2022
2 changes: 1 addition & 1 deletion packages/discord.js/src/managers/GuildChannelManager.js
Expand Up @@ -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<?GuildChannel|Collection<Snowflake, GuildChannel>>}
* @returns {Promise<?GuildChannel|ThreadChannel|Collection<Snowflake, ?GuildChannel>>}
* @example
* // Fetch all channels from the guild (excluding threads)
* message.guild.channels.fetch()
Expand Down
7 changes: 5 additions & 2 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -3376,8 +3376,11 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
public create(options: GuildChannelCreateOptions): Promise<TextChannel>;
public createWebhook(options: WebhookCreateOptions): Promise<Webhook>;
public edit(channel: GuildChannelResolvable, data: GuildChannelEditOptions): Promise<GuildChannel>;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<NonThreadGuildBasedChannel | null>;
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, NonThreadGuildBasedChannel>>;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<GuildBasedChannel | null>;
public fetch(
id?: undefined,
options?: BaseFetchOptions,
): Promise<Collection<Snowflake, NonThreadGuildBasedChannel | null>>;
public fetchWebhooks(channel: GuildChannelResolvable): Promise<Collection<Snowflake, Webhook>>;
public setPosition(
channel: GuildChannelResolvable,
Expand Down
6 changes: 3 additions & 3 deletions packages/discord.js/typings/index.test-d.ts
Expand Up @@ -1187,9 +1187,9 @@ declare const guildChannelManager: GuildChannelManager;
expectType<Promise<NewsChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildNews }));
expectType<Promise<StageChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildStageVoice }));

expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch());
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch(undefined, {}));
expectType<Promise<AnyChannel | null>>(guildChannelManager.fetch('0'));
expectType<Promise<Collection<Snowflake, AnyChannel | null>>>(guildChannelManager.fetch());
expectType<Promise<Collection<Snowflake, AnyChannel | null>>>(guildChannelManager.fetch(undefined, {}));
expectType<Promise<GuildBasedChannel | null>>(guildChannelManager.fetch('0'));

const channel = guildChannelManager.cache.first()!;

Expand Down