Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: channel unions (#3918 69d69f2) #3978

Merged
merged 4 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/structures/GuildChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,15 +576,6 @@ class GuildChannel extends Channel {
return this.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_CHANNELS, false);
}

/**
* Whether this GuildChannel is a partial
* @type {boolean}
* @readonly
*/
get partial() {
return false;
}

/**
* Whether the channel is viewable by the client user
* @type {boolean}
Expand Down
88 changes: 34 additions & 54 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ declare module 'discord.js' {
}

export class CategoryChannel extends GuildChannel {
public readonly children: Collection<Snowflake, Exclude<GuildChannelTypes, CategoryChannel>>;
public readonly children: Collection<Snowflake, GuildChannel>;
public type: 'category';
}

Expand All @@ -143,8 +143,8 @@ declare module 'discord.js' {
public deleted: boolean;
public id: Snowflake;
public type: keyof typeof ChannelType;
public delete(reason?: string): Promise<ChannelTypes>;
public fetch(): Promise<ChannelTypes>;
public delete(reason?: string): Promise<this>;
public fetch(): Promise<this>;
public toString(): string;
}

Expand Down Expand Up @@ -543,7 +543,7 @@ declare module 'discord.js' {
public recipient: User;
public readonly partial: false;
public type: 'dm';
public fetch(): Promise<DMChannel>;
public fetch(): Promise<this>;
}

export class Emoji extends Base {
Expand All @@ -563,7 +563,7 @@ declare module 'discord.js' {
export class Guild extends Base {
constructor(client: Client, data: object);
private _sortedRoles(): Collection<Snowflake, Role>;
private _sortedChannels(channel: Channel): Collection<Snowflake, GuildChannelTypes>;
private _sortedChannels(channel: Channel): Collection<Snowflake, GuildChannel>;
private _memberSpeakUpdate(user: Snowflake, speaking: boolean): void;

public readonly afkChannel: VoiceChannel | null;
Expand All @@ -578,7 +578,7 @@ declare module 'discord.js' {
public defaultMessageNotifications: DefaultMessageNotifications | number;
public deleted: boolean;
public description: string | null;
public embedChannel: GuildChannelTypes | null;
public embedChannel: GuildChannel | null;
public embedChannelID: Snowflake | null;
public embedEnabled: boolean;
public emojis: GuildEmojiManager;
Expand Down Expand Up @@ -710,7 +710,6 @@ declare module 'discord.js' {
public readonly members: Collection<Snowflake, GuildMember>;
public name: string;
public readonly parent: CategoryChannel | null;
public readonly partial: false;
public parentID: Snowflake | null;
public permissionOverwrites: Collection<Snowflake, PermissionOverwrites>;
public readonly permissionsLocked: boolean | null;
Expand Down Expand Up @@ -844,7 +843,7 @@ declare module 'discord.js' {

export class Invite extends Base {
constructor(client: Client, data: object);
public channel: GuildChannelTypes | PartialGroupDMChannel;
public channel: GuildChannel | PartialGroupDMChannel;
public code: string;
public readonly deletable: boolean;
public readonly createdAt: Date | null;
Expand Down Expand Up @@ -961,11 +960,11 @@ declare module 'discord.js' {
}

export class MessageCollector extends Collector<Snowflake, Message> {
constructor(channel: TextBasedChannelTypes, filter: CollectorFilter, options?: MessageCollectorOptions);
private _handleChannelDeletion(channel: TextBasedChannelTypes): void;
constructor(channel: TextChannel | DMChannel, filter: CollectorFilter, options?: MessageCollectorOptions);
private _handleChannelDeletion(channel: GuildChannel): void;
private _handleGuildDeletion(guild: Guild): void;

public channel: TextBasedChannelTypes;
public channel: Channel;
public options: MessageCollectorOptions;
public received: number;

Expand Down Expand Up @@ -1028,7 +1027,7 @@ declare module 'discord.js' {
roles: Snowflake[] | Collection<Snowflake, Role>,
everyone: boolean,
);
private _channels: Collection<Snowflake, GuildChannelTypes> | null;
private _channels: Collection<Snowflake, GuildChannel> | null;
private readonly _content: Message;
private _members: Collection<Snowflake, GuildMember> | null;

Expand All @@ -1037,7 +1036,7 @@ declare module 'discord.js' {
public everyone: boolean;
public readonly guild: Guild;
public has(
data: User | GuildMember | Role | GuildChannelTypes,
data: User | GuildMember | Role | GuildChannel,
options?: {
ignoreDirect?: boolean;
ignoreRoles?: boolean;
Expand Down Expand Up @@ -1093,9 +1092,9 @@ declare module 'discord.js' {
}

export class PermissionOverwrites {
constructor(guildChannel: GuildChannelTypes, data?: object);
constructor(guildChannel: GuildChannel, data?: object);
public allow: Readonly<Permissions>;
public readonly channel: GuildChannelTypes;
public readonly channel: GuildChannel;
public deny: Readonly<Permissions>;
public id: Snowflake;
public type: OverwriteType;
Expand Down Expand Up @@ -1136,7 +1135,7 @@ declare module 'discord.js' {

export class ReactionCollector extends Collector<Snowflake, MessageReaction> {
constructor(message: Message, filter: CollectorFilter, options?: ReactionCollectorOptions);
private _handleChannelDeletion(channel: TextBasedChannelTypes): void;
private _handleChannelDeletion(channel: GuildChannel): void;
private _handleGuildDeletion(guild: Guild): void;
private _handleMessageDeletion(message: Message): void;

Expand Down Expand Up @@ -1775,9 +1774,9 @@ declare module 'discord.js' {

//#region Managers

export class ChannelManager extends BaseManager<Snowflake, ChannelTypes, ChannelResolvable> {
export class ChannelManager extends BaseManager<Snowflake, Channel, ChannelResolvable> {
constructor(client: Client, iterable: Iterable<any>);
public fetch(id: Snowflake, cache?: boolean): Promise<ChannelTypes>;
public fetch(id: Snowflake, cache?: boolean): Promise<Channel>;
}

export abstract class BaseManager<K, Holds, R> {
Expand All @@ -1792,7 +1791,7 @@ declare module 'discord.js' {
public resolveID(resolvable: R): K | null;
}

export class GuildChannelManager extends BaseManager<Snowflake, GuildChannelTypes, GuildChannelResolvable> {
export class GuildChannelManager extends BaseManager<Snowflake, GuildChannel, GuildChannelResolvable> {
constructor(guild: Guild, iterable?: Iterable<any>);
public guild: Guild;
public create(name: string, options: GuildCreateChannelOptions & { type: 'voice' }): Promise<VoiceChannel>;
Expand Down Expand Up @@ -2125,10 +2124,6 @@ declare module 'discord.js' {
position: number;
}

type ChannelTypes = DMChannel | CategoryChannel | NewsChannel | StoreChannel | TextChannel | VoiceChannel;
type GuildChannelTypes = CategoryChannel | NewsChannel | StoreChannel | TextChannel | VoiceChannel;
type TextBasedChannelTypes = DMChannel | NewsChannel | TextChannel;

type ChannelResolvable = Channel | Snowflake;

interface ClientApplicationAsset {
Expand Down Expand Up @@ -2784,19 +2779,14 @@ declare module 'discord.js' {
[K in keyof Omit<
T,
'client' | 'createdAt' | 'createdTimestamp' | 'id' | 'partial' | 'fetch'
>]: // tslint:disable-next-line:ban-types
T[K] extends Function ? T[K] : T[K] | null;
>]: T[K] extends Function ? T[K] : T[K] | null; // tslint:disable-line:ban-types
};

interface PartialDMChannel extends Partialize<DMChannel,
'lastMessage' |
'lastMessageID' |
'messages' |
'recipient' |
'type' |
'typing' |
'typingCount'
> {
interface PartialDMChannel
extends Partialize<
DMChannel,
'lastMessage' | 'lastMessageID' | 'messages' | 'recipient' | 'type' | 'typing' | 'typingCount'
> {
lastMessage: null;
lastMessageID: undefined;
messages: MessageManager;
Expand All @@ -2820,16 +2810,11 @@ declare module 'discord.js' {
}[];
}

interface PartialGuildMember extends Partialize<GuildMember,
'bannable' |
'displayColor' |
'displayHexColor' |
'displayName' |
'guild' |
'kickable' |
'permissions' |
'roles'
> {
interface PartialGuildMember
extends Partialize<
GuildMember,
'bannable' | 'displayColor' | 'displayHexColor' | 'displayName' | 'guild' | 'kickable' | 'permissions' | 'roles'
> {
readonly bannable: boolean;
readonly displayColor: number;
readonly displayHexColor: string;
Expand All @@ -2842,16 +2827,11 @@ declare module 'discord.js' {
readonly roles: GuildMember['roles'];
}

interface PartialMessage extends Partialize<Message,
'attachments' |
'channel' |
'deletable' |
'editable' |
'mentions' |
'pinnable' |
'system' |
'url'
> {
interface PartialMessage
extends Partialize<
Message,
'attachments' | 'channel' | 'deletable' | 'editable' | 'mentions' | 'pinnable' | 'system' | 'url'
> {
attachments: Message['attachments'];
channel: Message['channel'];
readonly deletable: boolean;
Expand Down