export type CreateApiUsersMeChannelsArgs = {'Content-Type'?: string | undefined}; export type CreateApiUsersMeChannelsOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * create dm * * POST /users/@me/channels */ export const createApiUsersMeChannels = async (args: CreateApiUsersMeChannelsArgs, options: CreateApiUsersMeChannelsOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/users/@me/channels${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };