Skip to content

Commit

Permalink
getActiveThreads dep to getActiveGuildThreads
Browse files Browse the repository at this point in the history
  • Loading branch information
bsian03 committed Aug 17, 2021
1 parent bee0cfe commit b7b7fba
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
24 changes: 15 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,10 @@ declare namespace Eris {
before?: Date;
limit?: number;
}
interface ListedThreads<T extends ThreadChannel = AnyThreadChannel> {
interface ListedChannelThreads<T extends ThreadChannel = AnyThreadChannel> extends ListedGuildThreads<T> {
hasMore: boolean;
}
interface ListedGuildThreads<T extends ThreadChannel = AnyThreadChannel> {
members: ThreadMember[];
threads: T[];
}
Expand Down Expand Up @@ -1819,9 +1821,11 @@ declare namespace Eris {
executeWebhook(webhookID: string, token: string, options: WebhookPayload & { wait: true }): Promise<Message<GuildTextableChannel>>;
executeWebhook(webhookID: string, token: string, options: WebhookPayload): Promise<void>;
followChannel(channelID: string, webhookChannelID: string): Promise<ChannelFollow>;
getActiveThreads(channelID: string): Promise<ListedThreads>;
getArchivedThreads(channelID: string, type: "private", options?: GetArchivedThreadsOptions): Promise<ListedThreads<PrivateThreadChannel>>;
getArchivedThreads(channelID: string, type: "public", options?: GetArchivedThreadsOptions): Promise<ListedThreads<PublicThreadChannel>>;
getActiveGuildThreads(guildID: string): Promise<ListedGuildThreads>;
/** @deprecated */
getActiveThreads(channelID: string): Promise<ListedChannelThreads>;
getArchivedThreads(channelID: string, type: "private", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PrivateThreadChannel>>;
getArchivedThreads(channelID: string, type: "public", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PublicThreadChannel>>;
getBotGateway(): Promise<{ session_start_limit: { max_concurrency: number; remaining: number; reset_after: number; total: number }; shards: number; url: string }>;
getChannel(channelID: string): AnyChannel;
getChannelInvites(channelID: string): Promise<Invite[]>;
Expand Down Expand Up @@ -1850,7 +1854,7 @@ declare namespace Eris {
getGuildWidgetSettings(guildID: string): Promise<Widget>;
getInvite(inviteID: string, withCounts?: false): Promise<Invite<"withoutCount">>;
getInvite(inviteID: string, withCounts: true): Promise<Invite<"withCount">>;
getJoinedPrivateArchivedThreads(channelID: string, options?: GetArchivedThreadsOptions): Promise<ListedThreads<PrivateThreadChannel>>;
getJoinedPrivateArchivedThreads(channelID: string, options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PrivateThreadChannel>>;
getMessage(channelID: string, messageID: string): Promise<Message>;
getMessageReaction(channelID: string, messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise<User[]>;
/** @deprecated */
Expand Down Expand Up @@ -2181,6 +2185,7 @@ declare namespace Eris {
editWidget(options: Widget): Promise<Widget>;
fetchAllMembers(timeout?: number): Promise<number>;
fetchMembers(options?: FetchMembersOptions): Promise<Member[]>;
getActiveThreads(): Promise<ListedGuildThreads>;
getAuditLog(options?: GetGuildAuditLogOptions): Promise<GuildAuditLog>;
/** @deprecated */
getAuditLogs(limit?: number, before?: string, actionType?: number, userID?: string): Promise<GuildAuditLog>;
Expand Down Expand Up @@ -2748,11 +2753,12 @@ declare namespace Eris {
deleteMessages(messageIDs: string[], reason?: string): Promise<void>;
edit(options: Omit<EditChannelOptions, "icon" | "ownerID">, reason?: string): Promise<this>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<TextChannel>>;
getActiveThreads(): Promise<ListedThreads>;
getArchivedThreads(type: "private", options?: GetArchivedThreadsOptions): Promise<ListedThreads<PrivateThreadChannel>>;
getArchivedThreads(type: "public", options?: GetArchivedThreadsOptions): Promise<ListedThreads<PublicThreadChannel>>;
/** @deprecated */
getActiveThreads(): Promise<ListedChannelThreads>;
getArchivedThreads(type: "private", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PrivateThreadChannel>>;
getArchivedThreads(type: "public", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PublicThreadChannel>>;
getInvites(): Promise<(Invite<"withMetadata", TextChannel>)[]>;
getJoinedPrivateArchivedThreads(options: GetArchivedThreadsOptions): Promise<ListedThreads<PrivateThreadChannel>>;
getJoinedPrivateArchivedThreads(options: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PrivateThreadChannel>>;
getMessage(messageID: string): Promise<Message<TextChannel>>;
getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise<User[]>;
/** @deprecated */
Expand Down
16 changes: 15 additions & 1 deletion lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,21 @@ class Client extends EventEmitter {
}

/**
* Get all active threads in a channel
* Get all active threads in a guild
* @arg {String} guildID The ID of the guild
* @returns {Object} An object containing an array of `threads` and an array of `members`
*/
getActiveGuildThreads(guildID) {
return this.requestHandler.request("GET", Endpoints.THREADS_GUILD_ACTIVE(guildID), true).then((response) => {
return {
members: response.members.map((member) => new ThreadMember(member, this)),
threads: response.threads.map((thread) => Channel.from(thread, this))
};
});
}

/**
* [DEPRECATED] Get all active threads in a channel. Use getActiveGuildThreads instead
* @arg {String} channelID The ID of the channel
* @returns {Object} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
*/
Expand Down
1 change: 1 addition & 0 deletions lib/rest/Endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module.exports.THREAD_WITHOUT_MESSAGE = (channelID)
module.exports.THREADS_ACTIVE = (channelID) => `/channels/${channelID}/threads/active`;
module.exports.THREADS_ARCHIVED = (channelID, type) => `/channels/${channelID}/threads/archived/${type}`;
module.exports.THREADS_ARCHIVED_JOINED = (channelID) => `/channels/${channelID}/users/@me/threads/archived/private`;
module.exports.THREADS_GUILD_ACTIVE = (guildID) => `/guilds/${guildID}/threads/active`;
module.exports.USER = (userID) => `/users/${userID}`;
module.exports.USER_BILLING = (userID) => `/users/${userID}/billing`;
module.exports.USER_BILLING_PAYMENTS = (userID) => `/users/${userID}/billing/payments`;
Expand Down
8 changes: 8 additions & 0 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,14 @@ class Guild extends Base {
return this.shard.requestGuildMembers(this.id, options);
}

/**
* Get all active threads in this guild
* @returns {Object} An object containing an array of `threads` and an array of `members`
*/
getActiveThreads() {
return this.client.getActiveThreads.call(this.client, this.id);
}

/**
* Get the audit log for the guild
* @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
Expand Down
2 changes: 1 addition & 1 deletion lib/structures/TextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class TextChannel extends GuildChannel {
}

/**
* Get all active threads in this channelchannel
* [DEPRECATED] Get all active threads in this channel. Use guild.getActiveThreads instead
* @returns {Object} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
*/
getActiveThreads() {
Expand Down

0 comments on commit b7b7fba

Please sign in to comment.