* Remove GroupDMChannels

they sparked no joy

* Start partials for message deletion

* MessageUpdate partials

* Add partials as an opt-in client option

* Add fetch() to Message

* Message.author should never be undefined

* Fix channels being the wrong type

* Allow fetching channels

* Refactor and add reaction add partials

* Reaction remove partials

* Check for emoji first

* fix message fetching

janky

* User partials in audit logs

* refactor overwrite code

* guild member partials

* partials as a whitelist

* document GuildMember#fetch

* fix: check whether a structure is a partial, not whether cache is true

* typings: Updated for latest commit (#3075)

* partials: fix messageUpdate behaviour (now "old" message can be partial)

* partials: add warnings and docs

* partials: add partials to index.yml

* partials: tighten "partial" definitions

* partials: fix embed-only messages counting as partials
This commit is contained in:
Amish Shah
2019-02-13 17:39:39 +00:00
committed by GitHub
parent 8910fed729
commit 5c3f5d7048
35 changed files with 295 additions and 383 deletions

57
typings/index.d.ts vendored
View File

@@ -129,8 +129,9 @@ declare module 'discord.js' {
public readonly createdTimestamp: number;
public deleted: boolean;
public id: Snowflake;
public type: 'dm' | 'group' | 'text' | 'voice' | 'category' | 'unknown';
public type: 'dm' | 'text' | 'voice' | 'category' | 'unknown';
public delete(reason?: string): Promise<Channel>;
public fetch(): Promise<Channel>;
public toString(): string;
}
@@ -264,7 +265,6 @@ declare module 'discord.js' {
export class ClientUser extends User {
public mfaEnabled: boolean;
public verified: boolean;
public createGroupDM(recipients: GroupDMRecipientOptions[]): Promise<GroupDMChannel>;
public setActivity(options?: ActivityOptions): Promise<Presence>;
public setActivity(name: string, options?: ActivityOptions): Promise<Presence>;
public setAFK(afk: boolean): Promise<Presence>;
@@ -360,6 +360,7 @@ declare module 'discord.js' {
constructor(client: Client, data?: object);
public messages: MessageStore;
public recipient: User;
public readonly partial: boolean;
}
export class Emoji extends Base {
@@ -376,26 +377,6 @@ declare module 'discord.js' {
public toString(): string;
}
export class GroupDMChannel extends TextBasedChannel(Channel) {
constructor(client: Client, data?: object);
public applicationID: Snowflake;
public icon: string;
public managed: boolean;
public messages: MessageStore;
public name: string;
public nicks: Collection<Snowflake, string>;
public readonly owner: User;
public ownerID: Snowflake;
public recipients: Collection<Snowflake, User>;
public addUser(options: { user: UserResolvable, accessToken?: string, nick?: string }): Promise<GroupDMChannel>;
public edit (data: { icon?: string, name?: string }): Promise<GroupDMChannel>;
public equals(channel: GroupDMChannel): boolean;
public iconURL(options?: AvatarOptions): string;
public removeUser(user: UserResolvable): Promise<GroupDMChannel>;
public setIcon(icon: Base64Resolvable | BufferResolvable): Promise<GroupDMChannel>;
public setName(name: string): Promise<GroupDMChannel>;
}
export class Guild extends Base {
constructor(client: Client, data: object);
private _sortedRoles(): Collection<Snowflake, Role>;
@@ -570,12 +551,14 @@ declare module 'discord.js' {
public readonly kickable: boolean;
public readonly manageable: boolean;
public nickname: string;
public readonly partial: boolean;
public readonly permissions: Readonly<Permissions>;
public readonly presence: Presence;
public roles: GuildMemberRoleStore;
public user: User;
public readonly voice: VoiceState;
public ban(options?: BanOptions): Promise<GuildMember>;
public fetch(): Promise<GuildMember>;
public createDM(): Promise<DMChannel>;
public deleteDM(): Promise<DMChannel>;
public edit(data: GuildMemberEditData, reason?: string): Promise<GuildMember>;
@@ -619,7 +602,7 @@ declare module 'discord.js' {
export class Invite extends Base {
constructor(client: Client, data: object);
public channel: GuildChannel | GroupDMChannel;
public channel: GuildChannel;
public code: string;
public readonly createdAt: Date;
public createdTimestamp: number;
@@ -640,7 +623,7 @@ declare module 'discord.js' {
}
export class Message extends Base {
constructor(client: Client, data: object, channel: TextChannel | DMChannel | GroupDMChannel);
constructor(client: Client, data: object, channel: TextChannel | DMChannel);
private _edits: Message[];
private patch(data: object): void;
@@ -648,7 +631,7 @@ declare module 'discord.js' {
public application: ClientApplication;
public attachments: Collection<Snowflake, MessageAttachment>;
public author: User;
public channel: TextChannel | DMChannel | GroupDMChannel;
public channel: TextChannel | DMChannel;
public readonly cleanContent: string;
public content: string;
public readonly createdAt: Date;
@@ -665,6 +648,7 @@ declare module 'discord.js' {
public readonly member: GuildMember;
public mentions: MessageMentions;
public nonce: string;
public readonly partial: boolean;
public readonly pinnable: boolean;
public pinned: boolean;
public reactions: ReactionStore;
@@ -680,6 +664,7 @@ declare module 'discord.js' {
public edit(options: MessageEditOptions | MessageEmbed | APIMessage): Promise<Message>;
public equals(message: Message, rawData: object): boolean;
public fetchWebhook(): Promise<Webhook>;
public fetch(): Promise<Message>;
public pin(): Promise<Message>;
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;
public reply(content?: StringResolvable, options?: MessageOptions | MessageAdditions): Promise<Message | Message[]>;
@@ -706,7 +691,7 @@ declare module 'discord.js' {
}
export class MessageCollector extends Collector<Snowflake, Message> {
constructor(channel: TextChannel | DMChannel | GroupDMChannel, filter: CollectorFilter, options?: MessageCollectorOptions);
constructor(channel: TextChannel | DMChannel, filter: CollectorFilter, options?: MessageCollectorOptions);
public channel: Channel;
public options: MessageCollectorOptions;
public received: number;
@@ -1078,6 +1063,7 @@ declare module 'discord.js' {
public readonly dmChannel: DMChannel;
public id: Snowflake;
public locale: string;
public readonly partial: boolean;
public readonly presence: Presence;
public readonly tag: string;
public username: string;
@@ -1086,6 +1072,7 @@ declare module 'discord.js' {
public deleteDM(): Promise<DMChannel>;
public displayAvatarURL(options?: AvatarOptions): string;
public equals(user: User): boolean;
public fetch(): Promise<User>;
public toString(): string;
public typingDurationIn(channel: ChannelResolvable): number;
public typingIn(channel: ChannelResolvable): boolean;
@@ -1385,7 +1372,7 @@ declare module 'discord.js' {
}
export class MessageStore extends DataStore<Snowflake, Message, typeof Message, MessageResolvable> {
constructor(channel: TextChannel | DMChannel | GroupDMChannel, iterable?: Iterable<any>);
constructor(channel: TextChannel | DMChannel, iterable?: Iterable<any>);
public fetch(message: Snowflake): Promise<Message>;
public fetch(options?: ChannelLogsQueryOptions): Promise<Collection<Snowflake, Message>>;
public fetchPinned(): Promise<Collection<Snowflake, Message>>;
@@ -1607,6 +1594,7 @@ declare module 'discord.js' {
messageSweepInterval?: number;
fetchAllMembers?: boolean;
disableEveryone?: boolean;
partials?: PartialTypes[];
restWsBridgeTimeout?: number;
restTimeOffset?: number;
restSweepInterval?: number;
@@ -1676,7 +1664,6 @@ declare module 'discord.js' {
type Extendable = {
GuildEmoji: typeof GuildEmoji;
DMChannel: typeof DMChannel;
GroupDMChannel: typeof GroupDMChannel;
TextChannel: typeof TextChannel;
VoiceChannel: typeof VoiceChannel;
CategoryChannel: typeof CategoryChannel;
@@ -1711,13 +1698,6 @@ declare module 'discord.js' {
type: number;
};
type GroupDMRecipientOptions = {
user?: UserResolvable | Snowflake;
accessToken?: string;
nick?: string;
id?: Snowflake;
};
type GuildAuditLogsAction = keyof GuildAuditLogsActions;
type GuildAuditLogsActions = {
@@ -1934,7 +1914,7 @@ declare module 'discord.js' {
type MessageResolvable = Message | Snowflake;
type MessageTarget = TextChannel | DMChannel | GroupDMChannel | User | GuildMember | Webhook | WebhookClient;
type MessageTarget = TextChannel | DMChannel | User | GuildMember | Webhook | WebhookClient;
type MessageType = 'DEFAULT'
| 'RECIPIENT_ADD'
@@ -2023,6 +2003,11 @@ declare module 'discord.js' {
desktop?: ClientPresenceStatus
};
type PartialTypes = 'USER'
| 'CHANNEL'
| 'GUILD_MEMBER'
| 'MESSAGE';
type PresenceStatus = ClientPresenceStatus | 'offline';
type PresenceStatusData = ClientPresenceStatus | 'invisible';