export type GetApiGuildsGuildIdMembersSearchArgs = {limit?: string | undefined, query?: string | undefined, guild_id: string}; export type GetApiGuildsGuildIdMembersSearchOptions = {baseUrl: string, apikeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * search guild members * * GET /guilds/{guild_id}/members/search */ export const getApiGuildsGuildIdMembersSearch = async (args: GetApiGuildsGuildIdMembersSearchArgs, options: GetApiGuildsGuildIdMembersSearchOptions) => { const {baseUrl, fetch: fetchFn = fetch, apikeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.limit != null) query.append("limit", String(args.limit)) if (args.query != null) query.append("query", String(args.query)) if (apikeyAuth !== undefined) headers.set('authorization', `apikey ${apikeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/guilds/${encodeURIComponent(String(args.guild_id))}/members/search${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };