From 57ce190265daa860f7e11c5c8c456fb962180a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Wed, 24 Apr 2024 21:06:05 +0100 Subject: [PATCH 1/6] Fix with_member option not sending in `getThreadMember` --- lib/Client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Client.js b/lib/Client.js index 7d0e9e1a6..c64beb50c 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -3491,7 +3491,7 @@ class Client extends EventEmitter { * @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)); } From e1e0257826b65b36bf6e808dc266cbf081e5309f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Wed, 24 Apr 2024 21:27:44 +0100 Subject: [PATCH 2/6] Optional --- lib/Client.js | 2 +- lib/structures/ThreadChannel.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index c64beb50c..c22f2ead3 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -3487,7 +3487,7 @@ 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) { diff --git a/lib/structures/ThreadChannel.js b/lib/structures/ThreadChannel.js index 899cd66e8..817fc2096 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) { From 8099028855a2acffbdafde63a33d58dc5ea781bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Wed, 24 Apr 2024 21:28:54 +0100 Subject: [PATCH 3/6] Add options --- lib/Client.js | 12 ++++++++++-- lib/structures/ThreadChannel.js | 8 ++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index c22f2ead3..d7142f0be 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -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 817fc2096..e0b3ba446 100644 --- a/lib/structures/ThreadChannel.js +++ b/lib/structures/ThreadChannel.js @@ -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); } /** From b344518c397edfef95b1e4b32f16e22e69d548e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Wed, 24 Apr 2024 21:30:07 +0100 Subject: [PATCH 4/6] TS docs --- index.d.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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; From 9028f763f2ac619481dbf748a76356e4a54e1577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= <35053522+iiFDCT@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:18:40 +0100 Subject: [PATCH 5/6] Update lib/Client.js Co-authored-by: bsian03 --- lib/Client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Client.js b/lib/Client.js index d7142f0be..99ed8f224 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -3505,7 +3505,7 @@ class Client extends EventEmitter { * @arg {Boolean} [options.withMember] Whether to include the guild member object for each member of the thread * @returns {Promise>} */ - getThreadMembers(channelID, options) { + getThreadMembers(channelID, options = {}) { return this.requestHandler.request("GET", Endpoints.THREAD_MEMBERS(channelID), true, { after: options.after, limit: options.limit, From 8b9679e4c1976236f3254829116eca5992f9c48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Tue, 9 Jul 2024 18:33:14 +0100 Subject: [PATCH 6/6] Update ThreadMember.js --- lib/structures/ThreadMember.js | 3 +++ 1 file changed, 3 insertions(+) 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);