From d1fb9a88f45426d2b97da77a219f37ec84be7090 Mon Sep 17 00:00:00 2001 From: MARCROCK22 <57925328+MARCROCK22@users.noreply.github.com> Date: Tue, 7 May 2024 21:18:50 -0400 Subject: [PATCH] fix: files support cloudfare workers --- src/builders/Attachment.ts | 4 +++- src/client/httpclient.ts | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/builders/Attachment.ts b/src/builders/Attachment.ts index 9de9e80..6bd252e 100644 --- a/src/builders/Attachment.ts +++ b/src/builders/Attachment.ts @@ -38,7 +38,9 @@ export class AttachmentBuilder { * Creates a new Attachment instance. * @param data - The partial attachment data. */ - constructor(public data: Partial = { name: `${randomBytes(8).toString('base64url')}.jpg` }) {} + constructor( + public data: Partial = { name: `${randomBytes?.(8)?.toString('base64url') || 'default'}.jpg` }, + ) {} /** * Sets the name of the attachment. diff --git a/src/client/httpclient.ts b/src/client/httpclient.ts index d565995..8e0c8ce 100644 --- a/src/client/httpclient.ts +++ b/src/client/httpclient.ts @@ -195,9 +195,11 @@ export class HttpClient extends BaseClient { } r( - Response.json(response, { - headers, - }), + response instanceof FormData + ? new Response(response, { headers }) + : Response.json(response, { + headers, + }), ); }); });