rest: allow passing in a token type
vi did:web:vt3e.cat
Mon, 29 Jun 2026 03:59:52 +0100
2 files changed,
3 insertions(+),
3 deletions(-)
M
pkgs/rest/package.json
→
pkgs/rest/package.json
@@ -1,6 +1,6 @@
{ "name": "@purrkit/rest", - "version": "1.1.1", + "version": "1.1.2", "license": "EUPL-1.2", "files": [ "dist",
M
pkgs/rest/src/client.ts
→
pkgs/rest/src/client.ts
@@ -2,13 +2,13 @@ import type { ApiResponse, DiscordError, DiscordRestClient } from "./types";
export interface ClientOptions { token: string; + tokenType?: "Bot" | "Bearer"; baseUrl?: string; fetch?: (input: RequestInfo | URL | string, init?: RequestInit) => Promise<Response>; } export function RESTClient(options: ClientOptions): DiscordRestClient { const baseUrl = options.baseUrl || "https://discord.com/api/v10"; - const customFetch = options.fetch ?? globalThis.fetch; const executeRequest = async (@@ -41,7 +41,7 @@ try {
const isFormData = typeof FormData !== "undefined" && body instanceof FormData; const reqHeaders: Record<string, string> = { - Authorization: `Bot ${options.token}`, + Authorization: `${options.tokenType ?? "Bot"} ${options.token}`, ...headers, };