Skip to content

Commit

Permalink
fix(guild): allow to pass query into get
Browse files Browse the repository at this point in the history
  • Loading branch information
jaw0r3k authored and Jiralite committed Feb 21, 2024
1 parent 5988453 commit 92f7b3d
Showing 1 changed file with 5 additions and 32 deletions.
37 changes: 5 additions & 32 deletions packages/core/src/api/guild.ts
Expand Up @@ -104,16 +104,6 @@ import {
export class GuildsAPI {
public constructor(private readonly rest: REST) {}

/**
* Fetches a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild}
* @param guildId - The id of the guild
* @param options - The options for fetching the guild
* @deprecated Use the overload with a query instead.
*/
public async get(guildId: Snowflake, { signal }?: Pick<RequestData, 'signal'>): Promise<RESTGetAPIGuildResult>;

/**
* Fetches a guild
*
Expand All @@ -122,28 +112,11 @@ export class GuildsAPI {
* @param query - The query options for fetching the guild
* @param options - The options for fetching the guild
*/
public async get(
guildId: Snowflake,
query?: RESTGetAPIGuildQuery,
options?: Pick<RequestData, 'signal'>,
): Promise<RESTGetAPIGuildResult>;

public async get(
guildId: Snowflake,
queryOrOptions: Pick<RequestData, 'signal'> | RESTGetAPIGuildQuery = {},
options: Pick<RequestData, 'signal'> = {},
) {
const requestData: RequestData = {
signal: ('signal' in queryOrOptions ? queryOrOptions : options).signal,
};

const query = 'with_counts' in queryOrOptions ? makeURLSearchParams(queryOrOptions) : undefined;

if (query) {
requestData.query = query;
}

return this.rest.get(Routes.guild(guildId), requestData) as Promise<RESTGetAPIGuildResult>;
public async get(guildId: Snowflake, query: RESTGetAPIGuildQuery = {}, { signal }: Pick<RequestData, 'signal'> = {}) {
return this.rest.get(Routes.guild(guildId), {
query: makeURLSearchParams(query),
signal,
}) as Promise<RESTGetAPIGuildResult>;
}

/**
Expand Down

0 comments on commit 92f7b3d

Please sign in to comment.