From 7d8cb5154a0924a42cdb19fcee70883ab9763a7a Mon Sep 17 00:00:00 2001 From: GarboMuffin Date: Tue, 4 Jun 2024 16:52:18 -0500 Subject: [PATCH] NexusKitten/sgrab: handle errors better (#1512) if we got a 404 or other error then we shouldnt try to grab any information --- extensions/NexusKitten/sgrab.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/extensions/NexusKitten/sgrab.js b/extensions/NexusKitten/sgrab.js index 5d14597920..0212999961 100644 --- a/extensions/NexusKitten/sgrab.js +++ b/extensions/NexusKitten/sgrab.js @@ -231,6 +231,9 @@ const response = await Scratch.fetch( "https://scratchdb.lefty.one/v3/user/info/" + args.WHO ); + if (!response.ok) { + return ""; + } const jsonData = await response.json(); if (args.WHAT === "follower") { return jsonData.statistics.followers ?? ""; @@ -248,6 +251,9 @@ const response = await Scratch.fetch( "https://scratchdb.lefty.one/v3/user/info/" + args.WHO ); + if (!response.ok) { + return ""; + } const jsonData = await response.json(); if (args.WHAT === "follower") { return jsonData.statistics.ranks.followers ?? ""; @@ -269,6 +275,9 @@ const response = await Scratch.fetch( `https://trampoline.turbowarp.org/api/users/${args.WHO}` ); + if (!response.ok) { + return ""; + } const jsonData = await response.json(); if (args.WHAT === "about me") { return jsonData.profile.bio ?? ""; @@ -291,6 +300,9 @@ const response = await Scratch.fetch( `https://trampoline.turbowarp.org/api/projects/${args.WHO}` ); + if (!response.ok) { + return ""; + } const jsonData = await response.json(); if (args.WHAT === "love") { return jsonData.stats.loves ?? ""; @@ -310,6 +322,9 @@ const response = await Scratch.fetch( "https://scratchdb.lefty.one/v3/project/info/" + args.WHO ); + if (!response.ok) { + return ""; + } const jsonData = await response.json(); if (args.WHAT === "love") { return jsonData.statistics.ranks.loves ?? ""; @@ -329,6 +344,9 @@ const response = await Scratch.fetch( `https://trampoline.turbowarp.org/api/projects/${args.WHO}` ); + if (!response.ok) { + return ""; + } const jsonData = await response.json(); return jsonData.title ?? ""; } catch (error) { @@ -340,6 +358,9 @@ const response = await Scratch.fetch( `https://trampoline.turbowarp.org/api/projects/${args.WHO}` ); + if (!response.ok) { + return ""; + } const jsonData = await response.json(); return jsonData.author.username ?? ""; } catch (error) {