mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
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:
25
typings/index.d.ts
vendored
25
typings/index.d.ts
vendored
@@ -789,20 +789,20 @@ declare module 'discord.js' {
|
|||||||
public readonly position: number;
|
public readonly position: number;
|
||||||
public rawPosition: number;
|
public rawPosition: number;
|
||||||
public readonly viewable: boolean;
|
public readonly viewable: boolean;
|
||||||
public clone(options?: GuildChannelCloneOptions): Promise<GuildChannel>;
|
public clone(options?: GuildChannelCloneOptions): Promise<this>;
|
||||||
public createInvite(options?: InviteOptions): Promise<Invite>;
|
public createInvite(options?: InviteOptions): Promise<Invite>;
|
||||||
public createOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<GuildChannel>;
|
public createOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<this>;
|
||||||
public edit(data: ChannelData, reason?: string): Promise<GuildChannel>;
|
public edit(data: ChannelData, reason?: string): Promise<this>;
|
||||||
public equals(channel: GuildChannel): boolean;
|
public equals(channel: GuildChannel): boolean;
|
||||||
public fetchInvites(): Promise<Collection<string, Invite>>;
|
public fetchInvites(): Promise<Collection<string, Invite>>;
|
||||||
public lockPermissions(): Promise<GuildChannel>;
|
public lockPermissions(): Promise<this>;
|
||||||
public overwritePermissions(options?: { permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>, reason?: string }): Promise<GuildChannel>;
|
public overwritePermissions(options?: { permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>, reason?: string }): Promise<this>;
|
||||||
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
|
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
|
||||||
public setName(name: string, reason?: string): Promise<GuildChannel>;
|
public setName(name: string, reason?: string): Promise<this>;
|
||||||
public setParent(channel: GuildChannel | Snowflake, options?: { lockPermissions?: boolean, reason?: string }): Promise<GuildChannel>;
|
public setParent(channel: GuildChannel | Snowflake, options?: { lockPermissions?: boolean, reason?: string }): Promise<this>;
|
||||||
public setPosition(position: number, options?: { relative?: boolean, reason?: string }): Promise<GuildChannel>;
|
public setPosition(position: number, options?: { relative?: boolean, reason?: string }): Promise<this>;
|
||||||
public setTopic(topic: string, reason?: string): Promise<GuildChannel>;
|
public setTopic(topic: string, reason?: string): Promise<this>;
|
||||||
public updateOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<GuildChannel>;
|
public updateOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise<this>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StoreChannel extends GuildChannel {
|
export class StoreChannel extends GuildChannel {
|
||||||
@@ -1738,7 +1738,10 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
export class GuildChannelStore extends DataStore<Snowflake, GuildChannel, typeof GuildChannel, GuildChannelResolvable> {
|
export class GuildChannelStore extends DataStore<Snowflake, GuildChannel, typeof GuildChannel, GuildChannelResolvable> {
|
||||||
constructor(guild: Guild, iterable?: Iterable<any>);
|
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
|
// Hacky workaround because changing the signature of an overridden method errors
|
||||||
|
|||||||
Reference in New Issue
Block a user