export type UpdateApiChannelsChannelIdVoiceStatusArgs = {body: {status?: (string | null) | undefined}}; export type UpdateApiChannelsChannelIdVoiceStatusOptions = {baseUrl?: string | undefined, BotToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set a voice channel's status. * * PUT /channels/{channel_id}/voice-status */ export const updateApiChannelsChannelIdVoiceStatus = async (args: UpdateApiChannelsChannelIdVoiceStatusArgs, options?: UpdateApiChannelsChannelIdVoiceStatusOptions) => { const {baseUrl = "https://discord.com/api/v10", fetch: fetchFn = fetch, BotToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BotToken !== undefined) headers.set("Authorization", BotToken) const url = `${baseUrl.replace(/\/+$/, '')}/channels/${encodeURIComponent(String(args.channel_id))}/voice-status${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };