Repository: discordjs/discord.js
File: packages/core/src/api/guild.ts (TypeScript)

Code before:
	 *
	 * @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<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>;
	}

	/**
	 * Fetches a guild preview
	 *
	 * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-preview}
	 * @param guildId - The id of the guild to fetch the preview from
	 * @param options - The options for fetching the guild preview
	 */
	public async getPreview(guildId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
		return this.rest.get(Routes.guildPreview(guildId), {
			signal,
		}) as Promise<RESTGetAPIGuildPreviewResult>;
	}

	/**
	 * Creates a guild
	 *
	 * @see {@link https://discord.com/developers/docs/resources/guild#create-guild}
	 * @param body - The guild to create
	 * @param options - The options for creating the guild
	 */
	public async create(body: RESTPostAPIGuildsJSONBody, { signal }: Pick<RequestData, 'signal'> = {}) {

Review comment (suggestion):
```suggestion
		if ('with_counts' in queryOrOptions) {
			requestData.query = makeURLSearchParams(queryOrOptions);
		}
```

Code after:
	 *
	 * @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<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,
		};

		if ('with_counts' in queryOrOptions) {
			requestData.query = makeURLSearchParams(queryOrOptions);
		}

		return this.rest.get(Routes.guild(guildId), requestData) as Promise<RESTGetAPIGuildResult>;
	}

	/**
	 * Fetches a guild preview
	 *
	 * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-preview}
	 * @param guildId - The id of the guild to fetch the preview from
	 * @param options - The options for fetching the guild preview
	 */
	public async getPreview(guildId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
		return this.rest.get(Routes.guildPreview(guildId), {
			signal,
		}) as Promise<RESTGetAPIGuildPreviewResult>;
	}

	/**
	 * Creates a guild
	 *
	 * @see {@link https://discord.com/developers/docs/resources/guild#create-guild}
	 * @param body - The guild to create
	 * @param options - The options for creating the guild
	 */
	public async create(body: RESTPostAPIGuildsJSONBody, { signal }: Pick<RequestData, 'signal'> = {}) {
		return this.rest.post(Routes.guilds(), { body, signal }) as Promise<RESTPostAPIGuildsResult>;
	}