From d33fc741e3c1aa650a4a1e4ddb396e9f30c628a4 Mon Sep 17 00:00:00 2001 From: didinele Date: Sat, 29 Feb 2020 16:11:56 +0200 Subject: [PATCH] typings: Refactor how channel types are done (#3808) * refactor channel types * really weird solution to make what the PR promises possible, I might revert this * undo the dumb attempt * Update index.d.ts * fix GuildCreateChannelOptions#type * fix(typings): remove initializers from the enum * Update index.d.ts Co-authored-by: Crawl --- typings/index.d.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 810aeee74..70589cafa 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -133,6 +133,7 @@ declare module 'discord.js' { export class CategoryChannel extends GuildChannel { public readonly children: Collection; + public type: 'category'; } export class Channel extends Base { @@ -689,6 +690,7 @@ declare module 'discord.js' { public messages: MessageManager; public recipient: User; public readonly partial: false; + public type: 'dm'; public fetch(): Promise; } @@ -861,6 +863,7 @@ declare module 'discord.js' { public readonly permissionsLocked: boolean | null; public readonly position: number; public rawPosition: number; + public type: Exclude; public readonly viewable: boolean; public clone(options?: GuildChannelCloneOptions): Promise; public createInvite(options?: InviteOptions): Promise; @@ -1211,6 +1214,7 @@ declare module 'discord.js' { public messages: MessageManager; public nsfw: boolean; public topic: string | null; + public type: 'news'; public createWebhook( name: string, options?: { avatar?: BufferResolvable | Base64Resolvable; reason?: string }, @@ -1546,6 +1550,7 @@ declare module 'discord.js' { constructor(guild: Guild, data?: object); public messages: MessageManager; public nsfw: boolean; + public type: 'text'; public rateLimitPerUser: number; public topic: string | null; public createWebhook( @@ -1654,6 +1659,7 @@ declare module 'discord.js' { public readonly full: boolean; public readonly joinable: boolean; public readonly speakable: boolean; + public type: 'voice'; public userLimit: number; public join(): Promise; public leave(): void; @@ -2512,7 +2518,10 @@ declare module 'discord.js' { interface GuildCreateChannelOptions { permissionOverwrites?: OverwriteResolvable[] | Collection; topic?: string; - type?: Exclude; + type?: Exclude< + keyof typeof ChannelType | ChannelType, + 'dm' | 'group' | 'unknown' | ChannelType.dm | ChannelType.group | ChannelType.unknown + >; nsfw?: boolean; parent?: ChannelResolvable; bitrate?: number;