diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index fc5c6e461..f6a29b79c 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -26,6 +26,7 @@ import { type RESTGetAPIGuildPreviewResult, type RESTGetAPIGuildPruneCountQuery, type RESTGetAPIGuildPruneCountResult, + type RESTGetAPIGuildQuery, type RESTGetAPIGuildResult, type RESTGetAPIGuildRolesResult, type RESTGetAPIGuildScheduledEventQuery, @@ -109,9 +110,38 @@ export class GuildsAPI { * @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 = {}) { - return this.rest.get(Routes.guild(guildId), { signal }) as Promise; + public async get(guildId: Snowflake, { signal }?: Pick): Promise; + + /** + * Fetches a guild + * + * @see {@link https://discord.com/developers/docs/resources/guild#get-guild} + * @param guildId - The id of the guild + * @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, + ): Promise; + + public async get( + guildId: Snowflake, + queryOrOptions: Pick | RESTGetAPIGuildQuery = {}, + options: Pick = {}, + ) { + const requestData: RequestData = { + signal: ('signal' in queryOrOptions ? queryOrOptions : options).signal, + }; + + if ('with_counts' in queryOrOptions) { + requestData.query = makeURLSearchParams(queryOrOptions); + } + + return this.rest.get(Routes.guild(guildId), requestData) as Promise; } /**