import {z} from 'zod' export type GetApiApiV1LiveTrackingRaidingBotCommandsCmdArgs = {cmd: 'best-percent' | 'pull-count' | 'percent-and-pulls' | 'itemlevel', access_key?: string | undefined, raid: 'the-unbinding-of-kithix' | 'the-venomous-abyss' | 'the-tidebound-grotto' | 'sporefall' | 'tier-mn-1' | 'manaforge-omega' | 'liberation-of-undermine' | 'nerubar-palace' | 'blackrock-depths' | 'awakened-amirdrassil-the-dreams-hope' | 'awakened-aberrus-the-shadowed-crucible' | 'awakened-vault-of-the-incarnates' | 'amirdrassil-the-dreams-hope' | 'aberrus-the-shadowed-crucible' | 'vault-of-the-incarnates' | 'fated-sepulcher-of-the-first-ones' | 'fated-sanctum-of-domination' | 'fated-castle-nathria' | 'sepulcher-of-the-first-ones' | 'sanctum-of-domination' | 'castle-nathria' | 'nyalotha-the-waking-city' | 'the-eternal-palace' | 'crucible-of-storms' | 'battle-of-dazaralor' | 'uldir' | 'antorus-the-burning-throne' | 'tomb-of-sargeras' | 'the-nighthold' | 'trial-of-valor' | 'the-emerald-nightmare' | 'latest', boss: 'latest', difficulty: 'mythic' | 'heroic' | 'normal' | 'latest', period?: string | undefined, guild_id?: number | undefined, region?: ('us' | 'eu' | 'tw' | 'kr' | 'cn' | 'world') | undefined, realm?: string | undefined, guild?: string | undefined, template?: string | undefined}; export type GetApiApiV1LiveTrackingRaidingBotCommandsCmdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiApiV1LiveTrackingRaidingBotCommandsCmdResponse = z.string(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Return a pre-formatted string for use in Twitch/Discord bot commands. Supports template variables ($PCT, $BOSS, $PULL, $DIFFICULTY) for custom formatting. * * GET /api/v1/live-tracking/raiding/bot-commands/{cmd} */ export const getApiApiV1LiveTrackingRaidingBotCommandsCmd = async (args: GetApiApiV1LiveTrackingRaidingBotCommandsCmdArgs, options?: GetApiApiV1LiveTrackingRaidingBotCommandsCmdOptions) => { const {baseUrl = "http://raider.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.access_key != null) query.append("access_key", String(args.access_key)) if (args.raid != null) query.append("raid", String(args.raid)) if (args.boss != null) query.append("boss", String(args.boss)) if (args.difficulty != null) query.append("difficulty", String(args.difficulty)) if (args.period != null) query.append("period", String(args.period)) if (args.guild_id != null) query.append("guild_id", String(args.guild_id)) if (args.region != null) query.append("region", String(args.region)) if (args.realm != null) query.append("realm", String(args.realm)) if (args.guild != null) query.append("guild", String(args.guild)) if (args.template != null) query.append("template", String(args.template)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/live-tracking/raiding/bot-commands/${encodeURIComponent(String(args.cmd))}${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 validateResponse(getApiApiV1LiveTrackingRaidingBotCommandsCmdResponse, await res.json()) };