From cb9bf5b309fa2ce4e9c416373030114124139678 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Fri, 22 Jul 2022 12:09:52 +1000 Subject: Try catch handleFile --- slowcord/login/src/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'slowcord') diff --git a/slowcord/login/src/index.ts b/slowcord/login/src/index.ts index 68234e83..a17e9eaa 100644 --- a/slowcord/login/src/index.ts +++ b/slowcord/login/src/index.ts @@ -31,7 +31,7 @@ const toDataURL = async (url: string) => { const blob = await response.blob(); const buffer = Buffer.from(await blob.text()); return `data:${blob.type};base64,${buffer.toString("base64")}`; -} +}; class Discord { static getAccessToken = async (req: Request, res: Response) => { @@ -126,9 +126,14 @@ app.get("/oauth/:type", async (req, res) => { }); if (details.avatar_url) { - const avatar = await handleFile(`/avatars/${user.id}`, await toDataURL(details.avatar_url) as string); - user.avatar = avatar; - await user.save(); + try { + const avatar = await handleFile(`/avatars/${user.id}`, await toDataURL(details.avatar_url) as string); + user.avatar = avatar; + await user.save(); + } + catch (e) { + console.error(e); + } } } -- cgit 1.4.1