File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ type MockResponse = {
77 ok : boolean ;
88 text : ( ) => Promise < string > ;
99 json : ( ) => Promise < unknown > ;
10+ body : null ;
11+ arrayBuffer : ( ) => Promise < Buffer > ;
1012} ;
1113
1214const buildResponse = ( params : { status : number ; body ?: unknown } ) : MockResponse => {
@@ -17,6 +19,8 @@ const buildResponse = (params: { status: number; body?: unknown }): MockResponse
1719 ok : params . status >= 200 && params . status < 300 ,
1820 text : async ( ) => textPayload ,
1921 json : async ( ) => body ?? { } ,
22+ body : null ,
23+ arrayBuffer : async ( ) => Buffer . from ( textPayload ) ,
2024 } ;
2125} ;
2226
Original file line number Diff line number Diff line change 11// Discord plugin module implements pluralkit behavior.
22import { resolveFetch } from "openclaw/plugin-sdk/fetch-runtime" ;
3- import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http" ;
3+ import { readProviderJsonResponse , readResponseTextLimited } from "openclaw/plugin-sdk/provider-http" ;
44
55const PLURALKIT_API_BASE = "https://api.pluralkit.me/v2" ;
66const PLURALKIT_ERROR_BODY_LIMIT_BYTES = 8 * 1024 ;
@@ -59,5 +59,5 @@ export async function fetchPluralKitMessageInfo(params: {
5959 const detail = text . trim ( ) ? `: ${ text . trim ( ) } ` : "" ;
6060 throw new Error ( `PluralKit API failed (${ res . status } )${ detail } ` ) ;
6161 }
62- return ( await res . json ( ) ) as PluralKitMessageInfo ;
62+ return await readProviderJsonResponse < PluralKitMessageInfo > ( res , "PluralKit message" ) ;
6363}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import {
2222import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS } from "openclaw/plugin-sdk/media-runtime" ;
2323import { unlinkIfExists } from "openclaw/plugin-sdk/media-runtime" ;
2424import { parseStrictFiniteNumber } from "openclaw/plugin-sdk/number-runtime" ;
25- import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http" ;
25+ import { readProviderJsonResponse , readResponseTextLimited } from "openclaw/plugin-sdk/provider-http" ;
2626import type { RetryRunner } from "openclaw/plugin-sdk/retry-runtime" ;
2727import { writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime" ;
2828import { fetchWithSsrFGuard , type SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime" ;
@@ -351,7 +351,7 @@ async function requestVoiceUploadUrl(params: {
351351 if ( ! res . ok ) {
352352 throw await createVoiceRequestError ( res , "Upload URL request failed" ) ;
353353 }
354- return ( await res . json ( ) ) as UploadUrlResponse ;
354+ return await readProviderJsonResponse < UploadUrlResponse > ( res , "discord.voice.upload-url" ) ;
355355 } finally {
356356 await release ( ) ;
357357 }
You can’t perform that action at this time.
0 commit comments