mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
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 <almeidx@pm.me> * 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 <almeidx@pm.me> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -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.
|
* 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 {Snowflake} [id] The channel's id
|
||||||
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
||||||
* @returns {Promise<?GuildChannel|Collection<Snowflake, GuildChannel>>}
|
* @returns {Promise<?GuildChannel|ThreadChannel|Collection<Snowflake, ?GuildChannel>>}
|
||||||
* @example
|
* @example
|
||||||
* // Fetch all channels from the guild (excluding threads)
|
* // Fetch all channels from the guild (excluding threads)
|
||||||
* message.guild.channels.fetch()
|
* message.guild.channels.fetch()
|
||||||
|
|||||||
7
packages/discord.js/typings/index.d.ts
vendored
7
packages/discord.js/typings/index.d.ts
vendored
@@ -3364,8 +3364,11 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
|
|||||||
public create(options: GuildChannelCreateOptions): Promise<TextChannel>;
|
public create(options: GuildChannelCreateOptions): Promise<TextChannel>;
|
||||||
public createWebhook(options: WebhookCreateOptions): Promise<Webhook>;
|
public createWebhook(options: WebhookCreateOptions): Promise<Webhook>;
|
||||||
public edit(channel: GuildChannelResolvable, data: GuildChannelEditOptions): Promise<GuildChannel>;
|
public edit(channel: GuildChannelResolvable, data: GuildChannelEditOptions): Promise<GuildChannel>;
|
||||||
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<NonThreadGuildBasedChannel | null>;
|
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<GuildBasedChannel | null>;
|
||||||
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, NonThreadGuildBasedChannel>>;
|
public fetch(
|
||||||
|
id?: undefined,
|
||||||
|
options?: BaseFetchOptions,
|
||||||
|
): Promise<Collection<Snowflake, NonThreadGuildBasedChannel | null>>;
|
||||||
public fetchWebhooks(channel: GuildChannelResolvable): Promise<Collection<Snowflake, Webhook>>;
|
public fetchWebhooks(channel: GuildChannelResolvable): Promise<Collection<Snowflake, Webhook>>;
|
||||||
public setPosition(
|
public setPosition(
|
||||||
channel: GuildChannelResolvable,
|
channel: GuildChannelResolvable,
|
||||||
|
|||||||
@@ -1187,9 +1187,9 @@ declare const guildChannelManager: GuildChannelManager;
|
|||||||
expectType<Promise<NewsChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildNews }));
|
expectType<Promise<NewsChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildNews }));
|
||||||
expectType<Promise<StageChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildStageVoice }));
|
expectType<Promise<StageChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildStageVoice }));
|
||||||
|
|
||||||
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch());
|
expectType<Promise<Collection<Snowflake, AnyChannel | null>>>(guildChannelManager.fetch());
|
||||||
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch(undefined, {}));
|
expectType<Promise<Collection<Snowflake, AnyChannel | null>>>(guildChannelManager.fetch(undefined, {}));
|
||||||
expectType<Promise<AnyChannel | null>>(guildChannelManager.fetch('0'));
|
expectType<Promise<GuildBasedChannel | null>>(guildChannelManager.fetch('0'));
|
||||||
|
|
||||||
const channel = guildChannelManager.cache.first()!;
|
const channel = guildChannelManager.cache.first()!;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user