Skip to content

Commit

Permalink
types(CategoryChannel): createChannel should default to a text chan…
Browse files Browse the repository at this point in the history
…nel (#7132)
  • Loading branch information
suneettipirneni authored Dec 22, 2021
1 parent b763dab commit a0a5b0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 8 additions & 6 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,19 +494,21 @@ export type CategoryChannelTypes = ExcludeEnum<
export class CategoryChannel extends GuildChannel {
public readonly children: Collection<Snowflake, Exclude<NonThreadGuildBasedChannel, CategoryChannel>>;
public type: 'GUILD_CATEGORY';

public createChannel<T extends Exclude<CategoryChannelTypes, 'GUILD_STORE'>>(
name: string,
options: CategoryCreateChannelOptions & { type: T },
): Promise<MappedChannelCategoryTypes[T]>;

/** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */
public createChannel(
name: string,
options: CategoryCreateChannelOptions & { type: 'GUILD_STORE' },
options: CategoryCreateChannelOptions & { type: 'GUILD_STORE' | ChannelTypes.GUILD_STORE },
): Promise<StoreChannel>;
public createChannel<T extends CategoryChannelTypes>(
name: string,
options: CategoryCreateChannelOptions & { type: T },
): Promise<MappedChannelCategoryTypes[T]>;

public createChannel(
name: string,
options: CategoryCreateChannelOptions,
options?: CategoryCreateChannelOptions,
): Promise<Exclude<NonThreadGuildBasedChannel, CategoryChannel>>;
}

Expand Down
5 changes: 2 additions & 3 deletions typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,8 @@ declare const categoryChannel: CategoryChannel;
expectType<Promise<NewsChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_NEWS' }));
expectDeprecated(categoryChannel.createChannel('name', { type: 'GUILD_STORE' }));
expectType<Promise<StageChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_STAGE_VOICE' }));
expectType<Promise<TextChannel | VoiceChannel | NewsChannel | StoreChannel | StageChannel>>(
categoryChannel.createChannel('name', {}),
);
expectType<Promise<Exclude<NonThreadGuildBasedChannel, CategoryChannel>>>(categoryChannel.createChannel('name', {}));
expectType<Promise<Exclude<NonThreadGuildBasedChannel, CategoryChannel>>>(categoryChannel.createChannel('name'));
}

declare const guildChannelManager: GuildChannelManager;
Expand Down

0 comments on commit a0a5b0e

Please sign in to comment.