typings: make TypeScript interaction with channels better (#3469)

* make channel returning methods generic

* channel's type inference from kind of channel

* add extends

* rename generic due to name convention

* edit overload

* Update index.d.ts

* Update index.d.ts

* Update index.d.ts


Co-authored-by: Crawl <icrawltogo@gmail.com>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
BadCoder1337
2019-09-20 00:01:08 +03:00
committed by Crawl
parent d5831df7b1
commit d05334fd3c

25
typings/index.d.ts vendored
View File

@@ -789,20 +789,20 @@ declare module 'discord.js' {
public readonly position: number;
public rawPosition: number;
public readonly viewable: boolean;
public clone(options?: GuildChannelCloneOptions): Promise<GuildChannel>;
public clone(options?: GuildChannelCloneOptions): Promise<this>;
public createInvite(options?: InviteOptions): Promise<Invite>;
public createOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<GuildChannel>;
public edit(data: ChannelData, reason?: string): Promise<GuildChannel>;
public createOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<this>;
public edit(data: ChannelData, reason?: string): Promise<this>;
public equals(channel: GuildChannel): boolean;
public fetchInvites(): Promise<Collection<string, Invite>>;
public lockPermissions(): Promise<GuildChannel>;
public overwritePermissions(options?: { permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>, reason?: string }): Promise<GuildChannel>;
public lockPermissions(): Promise<this>;
public overwritePermissions(options?: { permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>, reason?: string }): Promise<this>;
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
public setName(name: string, reason?: string): Promise<GuildChannel>;
public setParent(channel: GuildChannel | Snowflake, options?: { lockPermissions?: boolean, reason?: string }): Promise<GuildChannel>;
public setPosition(position: number, options?: { relative?: boolean, reason?: string }): Promise<GuildChannel>;
public setTopic(topic: string, reason?: string): Promise<GuildChannel>;
public updateOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<GuildChannel>;
public setName(name: string, reason?: string): Promise<this>;
public setParent(channel: GuildChannel | Snowflake, options?: { lockPermissions?: boolean, reason?: string }): Promise<this>;
public setPosition(position: number, options?: { relative?: boolean, reason?: string }): Promise<this>;
public setTopic(topic: string, reason?: string): Promise<this>;
public updateOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<this>;
}
export class StoreChannel extends GuildChannel {
@@ -1738,7 +1738,10 @@ declare module 'discord.js' {
export class GuildChannelStore extends DataStore<Snowflake, GuildChannel, typeof GuildChannel, GuildChannelResolvable> {
constructor(guild: Guild, iterable?: Iterable<any>);
public create(name: string, options?: GuildCreateChannelOptions): Promise<TextChannel | VoiceChannel | CategoryChannel>;
public create(name: string, options: GuildCreateChannelOptions & { type: 'voice' }): Promise<VoiceChannel>;
public create(name: string, options: GuildCreateChannelOptions & { type: 'category' }): Promise<CategoryChannel>;
public create(name: string, options?: GuildCreateChannelOptions & { type?: 'text' }): Promise<TextChannel>;
public create(name: string, options: GuildCreateChannelOptions): Promise<TextChannel | VoiceChannel | CategoryChannel>;
}
// Hacky workaround because changing the signature of an overridden method errors