mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
feat(thread)!: Add query to getting a thread member (#11136)
BREAKING CHANGE: Third parameter of `ThreadsAPI#getMember()` is now `query`, pushing `options` to the fourth. * feat(thread): add query to getting a thread member * Apply suggestion from @almeidx Co-authored-by: Almeida <github@almeidx.dev> * Apply suggestion from @almeidx Co-authored-by: Almeida <github@almeidx.dev> --------- Co-authored-by: Almeida <github@almeidx.dev>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
/* eslint-disable jsdoc/check-param-names */
|
||||
|
||||
import type { RequestData, REST } from '@discordjs/rest';
|
||||
import { makeURLSearchParams, type RequestData, type REST } from '@discordjs/rest';
|
||||
import {
|
||||
Routes,
|
||||
type APIThreadMember,
|
||||
type RESTGetAPIChannelThreadMemberQuery,
|
||||
type RESTGetAPIChannelThreadMemberResult,
|
||||
type RESTGetAPIChannelThreadMembersResult,
|
||||
type Snowflake,
|
||||
} from 'discord-api-types/v10';
|
||||
@@ -71,14 +72,43 @@ export class ThreadsAPI {
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#get-thread-member}
|
||||
* @param threadId - The id of the thread to fetch the member from
|
||||
* @param userId - The id of the user
|
||||
* @param query - The query for fetching the member
|
||||
* @param options - The options for fetching the member
|
||||
*/
|
||||
public async getMember(
|
||||
threadId: Snowflake,
|
||||
userId: Snowflake,
|
||||
query: RESTGetAPIChannelThreadMemberQuery & { with_member: true },
|
||||
options?: Pick<RequestData, 'auth' | 'signal'>,
|
||||
): Promise<Required<Pick<RESTGetAPIChannelThreadMemberResult, 'member'>> & RESTGetAPIChannelThreadMemberResult>;
|
||||
|
||||
/**
|
||||
* Fetches a member of a thread
|
||||
*
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#get-thread-member}
|
||||
* @param threadId - The id of the thread to fetch the member from
|
||||
* @param userId - The id of the user
|
||||
* @param query - The query for fetching the member
|
||||
* @param options - The options for fetching the member
|
||||
*/
|
||||
public async getMember(
|
||||
threadId: Snowflake,
|
||||
userId: Snowflake,
|
||||
query?: RESTGetAPIChannelThreadMemberQuery,
|
||||
options?: Pick<RequestData, 'auth' | 'signal'>,
|
||||
): Promise<RESTGetAPIChannelThreadMemberResult>;
|
||||
|
||||
public async getMember(
|
||||
threadId: Snowflake,
|
||||
userId: Snowflake,
|
||||
query: RESTGetAPIChannelThreadMemberQuery = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.get(Routes.threadMembers(threadId, userId), { auth, signal }) as Promise<APIThreadMember>;
|
||||
return this.rest.get(Routes.threadMembers(threadId, userId), {
|
||||
auth,
|
||||
signal,
|
||||
query: makeURLSearchParams(query),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user