diff --git a/index.d.ts b/index.d.ts index 561822bae..c1038f023 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1730,6 +1730,11 @@ declare namespace Eris { before?: Date; limit?: number; } + interface GetThreadMembersOptions { + after?: string; + limit?: number; + withMember?: boolean; + } interface ListedChannelThreads extends ListedGuildThreads { hasMore: boolean; } @@ -3021,7 +3026,8 @@ declare namespace Eris { }[]>; getSelfSettings(): Promise; getStageInstance(channelID: string): Promise; - getThreadMembers(channelID: string): Promise; + getThreadMember(channelID: string, userID: string, withMember?: boolean): Promise; + getThreadMembers(channelID: string, options?: GetThreadMembersOptions): Promise; getUserProfile(userID: string): Promise; getVoiceRegions(guildID?: string): Promise; getWebhook(webhookID: string, token?: string): Promise; @@ -4107,7 +4113,7 @@ declare namespace Eris { constructor(data: BaseData, client: Client); edit(options: EditThreadChannelOptions, reason?: string): Promise; getMember(userID: string, withMember?: boolean): Promise; - getMembers(): Promise; + getMembers(options?: GetThreadMembersOptions): Promise; getPins(): Promise[]>; join(userID?: string): Promise; leave(userID?: string): Promise; diff --git a/lib/Client.js b/lib/Client.js index 7d0e9e1a6..99ed8f224 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -3487,11 +3487,11 @@ class Client extends EventEmitter { * Get a member that is part of a thread channel * @arg {String} channelID The ID of the thread channel * @arg {String} userID The ID of the user - * @arg {Boolean} withMember Whether to include the guild member object within the response + * @arg {Boolean} [withMember] Whether to include the guild member object within the response * @returns {Promise} */ getThreadMember(channelID, userID, withMember) { - return this.requestHandler.request("GET", Endpoints.THREAD_MEMBER(channelID, userID), { + return this.requestHandler.request("GET", Endpoints.THREAD_MEMBER(channelID, userID), true, { with_member: withMember }).then((threadMember) => new ThreadMember(threadMember, this)); } @@ -3499,10 +3499,18 @@ class Client extends EventEmitter { /** * Get a list of members that are part of a thread channel * @arg {String} channelID The ID of the thread channel + * @arg {Object} [options] Options for the request + * @arg {String} [options.after] Get members after this user ID + * @arg {Number} [options.limit=100] The maximum number of thread members to fetch (1-100) + * @arg {Boolean} [options.withMember] Whether to include the guild member object for each member of the thread * @returns {Promise>} */ - getThreadMembers(channelID) { - return this.requestHandler.request("GET", Endpoints.THREAD_MEMBERS(channelID), true).then((members) => members.map((member) => new ThreadMember(member, this))); + getThreadMembers(channelID, options = {}) { + return this.requestHandler.request("GET", Endpoints.THREAD_MEMBERS(channelID), true, { + after: options.after, + limit: options.limit, + with_member: options.withMember + }).then((members) => members.map((member) => new ThreadMember(member, this))); } /** diff --git a/lib/structures/ThreadChannel.js b/lib/structures/ThreadChannel.js index 899cd66e8..e0b3ba446 100644 --- a/lib/structures/ThreadChannel.js +++ b/lib/structures/ThreadChannel.js @@ -60,7 +60,7 @@ class ThreadChannel extends GuildTextableChannel { /** * Get a member that is part of the thread channel * @arg {String} userID The ID of the user - * @arg {Boolean} withMember Whether to include the guild member object within the response + * @arg {Boolean} [withMember] Whether to include the guild member object within the response * @returns {Promise} */ getMember(userID, withMember) { @@ -69,10 +69,14 @@ class ThreadChannel extends GuildTextableChannel { /** * Get a list of members that are part of this thread channel + * @arg {Object} [options] Options for the request + * @arg {String} [options.after] Get members after this user ID + * @arg {Number} [options.limit=100] The maximum number of thread members to fetch (1-100) + * @arg {Boolean} [options.withMember] Whether to include the guild member object for each member of the thread * @returns {Promise>} */ - getMembers() { - return this._client.getThreadMembers.call(this._client, this.id); + getMembers(options) { + return this._client.getThreadMembers.call(this._client, this.id, options); } /** diff --git a/lib/structures/ThreadMember.js b/lib/structures/ThreadMember.js index 9ccf544dc..500cf52a5 100644 --- a/lib/structures/ThreadMember.js +++ b/lib/structures/ThreadMember.js @@ -19,6 +19,9 @@ class ThreadMember extends Base { if(data.member !== undefined) { const guild = this._client.guilds.get(this._client.threadGuildMap[this.threadID]); + if(data.user_id) { + data.member.id = data.user_id; + } this.guildMember = guild.members.update(data.member, guild); if(data.presence !== undefined) { this.guildMember.update(data.presence);