From a4023da1236ba75b77d4b9dcb1875a32f5f2715d Mon Sep 17 00:00:00 2001 From: Erin Date: Tue, 16 Nov 2021 16:51:35 -0500 Subject: [PATCH] fix(typings): normalize Textable, fix deprecations (#1299) --- index.d.ts | 97 ++++++++++++++------------------- lib/structures/ThreadChannel.js | 17 ++++-- 2 files changed, 51 insertions(+), 63 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9c838fa29..795edf93b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -323,7 +323,6 @@ declare namespace Eris { purge(options: PurgeChannelOptions): Promise; removeMessageReactionEmoji(messageID: string, reaction: string): Promise; removeMessageReactions(messageID: string): Promise; - sendTyping(): Promise; } interface PartialChannel { bitrate?: number; @@ -350,32 +349,32 @@ declare namespace Eris { addMessageReaction(messageID: string, reaction: string): Promise; /** @deprecated */ addMessageReaction(messageID: string, reaction: string, userID: string): Promise; - createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise; + createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; deleteMessage(messageID: string, reason?: string): Promise; - editMessage(messageID: string, content: MessageContentEdit): Promise; - getMessage(messageID: string): Promise; + editMessage(messageID: string, content: MessageContentEdit): Promise>; + getMessage(messageID: string): Promise>; getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; /** @deprecated */ getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; - getMessages(options?: GetMessagesOptions): Promise; + getMessages(options?: GetMessagesOptions): Promise[]>; /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise; - getPins(): Promise; + getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; + getPins(): Promise[]>; pinMessage(messageID: string): Promise; removeMessageReaction(messageID: string, reaction: string, userID?: string): Promise; sendTyping(): Promise; unpinMessage(messageID: string): Promise; unsendMessage(messageID: string): Promise; } - // @ts-ignore ts(2430) - ThreadTextable can't properly extend Textable because of getMessageReaction deprecated overload interface ThreadTextable extends Textable { lastPinTimestamp?: number; - createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; - editMessage(messageID: string, content: MessageContentEdit): Promise>; - getMessage(messageID: string): Promise>; - getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; - getMessages(options?: GetMessagesOptions): Promise[]>; - getPins(): Promise[]>; + deleteMessages(messageIDs: string[], reason?: string): Promise; + getMembers(): Promise; + join(userID: string): Promise; + leave(userID: string): Promise; + purge(options: PurgeChannelOptions): Promise; + removeMessageReactionEmoji(messageID: string, reaction: string): Promise; + removeMessageReactions(messageID: string): Promise; } interface WebhookData { channelID: string; @@ -3120,27 +3119,21 @@ declare namespace Eris { rateLimitPerUser: 0; type: Constants["ChannelTypes"]["GUILD_NEWS"]; createInvite(options?: CreateInviteOptions, reason?: string): Promise>; - createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; + createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; createThreadWithMessage(messageID: string, options: CreateThreadOptions): Promise; crosspostMessage(messageID: string): Promise>; - editMessage(messageID: string, content: MessageContentEdit): Promise>; + editMessage(messageID: string, content: MessageContentEdit): Promise>; follow(webhookChannelID: string): Promise; getInvites(): Promise<(Invite<"withMetadata", NewsChannel>)[]>; - getMessage(messageID: string): Promise>; - getMessages(options?: GetMessagesOptions): Promise[]>; + getMessage(messageID: string): Promise>; + getMessages(options?: GetMessagesOptions): Promise[]>; /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; - getPins(): Promise[]>; + getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; + getPins(): Promise[]>; } export class NewsThreadChannel extends ThreadChannel { type: Constants["ChannelTypes"]["GUILD_NEWS_THREAD"]; - createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; - edit(options: Pick, reason?: string): Promise; - editMessage(messageID: string, content: MessageContentEdit): Promise>; - getMessage(messageID: string): Promise>; - getMessages(options?: GetMessagesOptions): Promise[]>; - getPins(): Promise[]>; } export class Permission extends Base { @@ -3183,17 +3176,17 @@ declare namespace Eris { addMessageReaction(messageID: string, reaction: string): Promise; /** @deprecated */ addMessageReaction(messageID: string, reaction: string, userID: string): Promise; - createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; + createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; deleteMessage(messageID: string, reason?: string): Promise; - editMessage(messageID: string, content: MessageContentEdit): Promise>; - getMessage(messageID: string): Promise>; + editMessage(messageID: string, content: MessageContentEdit): Promise>; + getMessage(messageID: string): Promise>; getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; /** @deprecated */ getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; - getMessages(options?: GetMessagesOptions): Promise[]>; + getMessages(options?: GetMessagesOptions): Promise[]>; /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; - getPins(): Promise[]>; + getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; + getPins(): Promise[]>; leave(): Promise; pinMessage(messageID: string): Promise; removeMessageReaction(messageID: string, reaction: string): Promise; @@ -3209,22 +3202,11 @@ declare namespace Eris { export class PrivateThreadChannel extends ThreadChannel { threadMetadata: PrivateThreadMetadata; type: Constants["ChannelTypes"]["GUILD_PRIVATE_THREAD"]; - createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; - edit(options: Pick, reason?: string): Promise; - editMessage(messageID: string, content: MessageContentEdit): Promise>; - getMessage(messageID: string): Promise>; - getMessages(options?: GetMessagesOptions): Promise[]>; - getPins(): Promise[]>; } export class PublicThreadChannel extends ThreadChannel { type: GuildPublicThreadChannelTypes; - createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; edit(options: Pick, reason?: string): Promise; - editMessage(messageID: string, content: MessageContentEdit): Promise>; - getMessage(messageID: string): Promise>; - getMessages(options?: GetMessagesOptions): Promise[]>; - getPins(): Promise[]>; } export class Relationship extends Base implements Omit { @@ -3434,28 +3416,28 @@ declare namespace Eris { /** @deprecated */ addMessageReaction(messageID: string, reaction: string, userID: string): Promise; createInvite(options?: CreateInviteOptions, reason?: string): Promise>; - createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; + createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; createThreadWithMessage(messageID: string, options: CreateThreadOptions): Promise; createThreadWithoutMessage(options: CreateThreadWithoutMessageOptions): Promise; createWebhook(options: { name: string; avatar?: string | null }, reason?: string): Promise; deleteMessage(messageID: string, reason?: string): Promise; deleteMessages(messageIDs: string[], reason?: string): Promise; edit(options: Omit, reason?: string): Promise; - editMessage(messageID: string, content: MessageContentEdit): Promise>; + editMessage(messageID: string, content: MessageContentEdit): Promise>; /** @deprecated */ getActiveThreads(): Promise; getArchivedThreads(type: "private", options?: GetArchivedThreadsOptions): Promise>; getArchivedThreads(type: "public", options?: GetArchivedThreadsOptions): Promise>; getInvites(): Promise<(Invite<"withMetadata", TextChannel>)[]>; getJoinedPrivateArchivedThreads(options: GetArchivedThreadsOptions): Promise>; - getMessage(messageID: string): Promise>; + getMessage(messageID: string): Promise>; getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; /** @deprecated */ getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; - getMessages(options?: GetMessagesOptions): Promise[]>; + getMessages(options?: GetMessagesOptions): Promise[]>; /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; - getPins(): Promise[]>; + getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; + getPins(): Promise[]>; getWebhooks(): Promise; pinMessage(messageID: string): Promise; purge(options: PurgeChannelOptions): Promise; @@ -3469,9 +3451,6 @@ declare namespace Eris { unsendMessage(messageID: string): Promise; } - type A = T; - type B = A; - export class ThreadChannel extends GuildChannel implements ThreadTextable { lastMessageID: string; lastPinTimestamp?: number; @@ -3486,16 +3465,20 @@ declare namespace Eris { type: GuildThreadChannelTypes; constructor(data: BaseData, client: Client, messageLimit?: number); addMessageReaction(messageID: string, reaction: string): Promise; - createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; + createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; deleteMessage(messageID: string, reason?: string): Promise; deleteMessages(messageIDs: string[], reason?: string): Promise; edit(options: Pick, reason?: string): Promise; - editMessage(messageID: string, content: MessageContentEdit): Promise>; + editMessage(messageID: string, content: MessageContentEdit): Promise>; getMembers(): Promise; - getMessage(messageID: string): Promise>; + getMessage(messageID: string): Promise>; getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; - getMessages(options?: GetMessagesOptions): Promise[]>; - getPins(): Promise[]>; + /** @deprecated */ + getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; + getMessages(options?: GetMessagesOptions): Promise[]>; + /** @deprecated */ + getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; + getPins(): Promise[]>; join(userID?: string): Promise; leave(userID?: string): Promise; pinMessage(messageID: string): Promise; diff --git a/lib/structures/ThreadChannel.js b/lib/structures/ThreadChannel.js index 66c65012f..22ef21fbb 100644 --- a/lib/structures/ThreadChannel.js +++ b/lib/structures/ThreadChannel.js @@ -194,26 +194,31 @@ class ThreadChannel extends GuildChannel { * Get a list of users who reacted with a specific reaction * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. + * @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior) * @arg {Number} [options.limit=100] The maximum number of users to get * @arg {String} [options.after] Get users after this user ID + * @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter + * @arg {String} [after] [DEPRECATED] Get users after this user ID * @returns {Promise>} */ - getMessageReaction(messageID, reaction, options) { - return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options); + getMessageReaction(messageID, reaction, options, before, after) { + return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options, before, after); } /** * Get previous messages in the channel - * @arg {Object} [options] Options for the request + * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` * @arg {String} [options.after] Get messages after this message ID * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) * @arg {String} [options.before] Get messages before this message ID * @arg {Number} [options.limit=50] The max number of messages to get + * @arg {String} [before] [DEPRECATED] Get messages before this message ID + * @arg {String} [after] [DEPRECATED] Get messages after this message ID + * @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100) * @returns {Promise>} */ - getMessages(options) { - return this.client.getMessages.call(this.client, this.id, options); + getMessages(options, before, after, around) { + return this.client.getMessages.call(this.client, this.id, options, before, after, around); } /**