File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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 {
4+ readProviderJsonResponse ,
5+ readResponseTextLimited ,
6+ } from "openclaw/plugin-sdk/provider-http" ;
47
58const PLURALKIT_API_BASE = "https://api.pluralkit.me/v2" ;
69const PLURALKIT_ERROR_BODY_LIMIT_BYTES = 8 * 1024 ;
@@ -59,5 +62,5 @@ export async function fetchPluralKitMessageInfo(params: {
5962 const detail = text . trim ( ) ? `: ${ text . trim ( ) } ` : "" ;
6063 throw new Error ( `PluralKit API failed (${ res . status } )${ detail } ` ) ;
6164 }
62- return ( await res . json ( ) ) as PluralKitMessageInfo ;
65+ return await readProviderJsonResponse < PluralKitMessageInfo > ( res , "discord.pluralkit" ) ;
6366}
Original file line number Diff line number Diff line change 11// Discord plugin module implements send.webhook behavior.
22import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime" ;
33import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts" ;
4- import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http" ;
4+ import {
5+ readProviderJsonResponse ,
6+ readResponseTextLimited ,
7+ } from "openclaw/plugin-sdk/provider-http" ;
58import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime" ;
69import { resolveDiscordClientAccountContext } from "./client.js" ;
710import {
@@ -120,7 +123,9 @@ export async function sendWebhookMessageDiscord(
120123 await throwWebhookResponseError ( response ) ;
121124 }
122125
123- const payload = ( await response . json ( ) . catch ( ( ) => ( { } ) ) ) as {
126+ const payload = ( await readProviderJsonResponse ( response , "discord.webhook" ) . catch (
127+ ( ) => ( { } ) ,
128+ ) ) as {
124129 id ?: string ;
125130 channel_id ?: string ;
126131 } ;
Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ 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 {
26+ readResponseTextLimited ,
27+ readProviderJsonResponse ,
28+ } from "openclaw/plugin-sdk/provider-http" ;
2629import type { RetryRunner } from "openclaw/plugin-sdk/retry-runtime" ;
2730import { writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime" ;
2831import { fetchWithSsrFGuard , type SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime" ;
@@ -351,7 +354,7 @@ async function requestVoiceUploadUrl(params: {
351354 if ( ! res . ok ) {
352355 throw await createVoiceRequestError ( res , "Upload URL request failed" ) ;
353356 }
354- return ( await res . json ( ) ) as UploadUrlResponse ;
357+ return await readProviderJsonResponse < UploadUrlResponse > ( res , "discord.voice-message" ) ;
355358 } finally {
356359 await release ( ) ;
357360 }
You can’t perform that action at this time.
0 commit comments