Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ThreadChannel): Thread member pagination #1497

Merged
merged 7 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,11 @@ declare namespace Eris {
before?: Date;
limit?: number;
}
interface GetThreadMembersOptions {
after?: string;
limit?: number;
withMember?: boolean;
}
interface ListedChannelThreads<T extends ThreadChannel = AnyThreadChannel> extends ListedGuildThreads<T> {
hasMore: boolean;
}
Expand Down Expand Up @@ -3021,7 +3026,8 @@ declare namespace Eris {
}[]>;
getSelfSettings(): Promise<UserSettings>;
getStageInstance(channelID: string): Promise<StageInstance>;
getThreadMembers(channelID: string): Promise<ThreadMember[]>;
getThreadMember(channelID: string, userID: string, withMember?: boolean): Promise<ThreadMember>;
getThreadMembers(channelID: string, options?: GetThreadMembersOptions): Promise<ThreadMember[]>;
getUserProfile(userID: string): Promise<UserProfile>;
getVoiceRegions(guildID?: string): Promise<VoiceRegion[]>;
getWebhook(webhookID: string, token?: string): Promise<Webhook>;
Expand Down Expand Up @@ -4107,7 +4113,7 @@ declare namespace Eris {
constructor(data: BaseData, client: Client);
edit(options: EditThreadChannelOptions, reason?: string): Promise<this>;
getMember(userID: string, withMember?: boolean): Promise<ThreadMember>;
getMembers(): Promise<ThreadMember[]>;
getMembers(options?: GetThreadMembersOptions): Promise<ThreadMember[]>;
getPins(): Promise<Message<this>[]>;
join(userID?: string): Promise<void>;
leave(userID?: string): Promise<void>;
Expand Down
16 changes: 12 additions & 4 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3487,22 +3487,30 @@ 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<ThreadMember>}
*/
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));
}

/**
* 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<Array<ThreadMember>>}
*/
getThreadMembers(channelID) {
return this.requestHandler.request("GET", Endpoints.THREAD_MEMBERS(channelID), true).then((members) => members.map((member) => new ThreadMember(member, this)));
getThreadMembers(channelID, options) {
conorwastakenwastaken marked this conversation as resolved.
Show resolved Hide resolved
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)));
bsian03 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
10 changes: 7 additions & 3 deletions lib/structures/ThreadChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<ThreadMember>}
*/
getMember(userID, withMember) {
Expand All @@ -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<Array<ThreadMember>>}
*/
getMembers() {
return this._client.getThreadMembers.call(this._client, this.id);
getMembers(options) {
return this._client.getThreadMembers.call(this._client, this.id, options);
}

/**
Expand Down