summary refs log tree commit diff
path: root/api/src/routes
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-02-04 19:59:13 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-02-04 19:59:13 +1100
commitb512fa49b08e9f4ef9cdba3537335c37bb663180 (patch)
tree7552388d7fe8c990cdd2483c74b78003c86f241c /api/src/routes
parentMerge pull request #612 from ImAaronFR/patch-3 (diff)
downloadserver-b512fa49b08e9f4ef9cdba3537335c37bb663180.tar.xz
Remove nulled properties from GET `/channels/#id/messages` for improved compatibility with some client ( discord.js )
Diffstat (limited to 'api/src/routes')
-rw-r--r--api/src/routes/channels/#channel_id/messages/index.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/api/src/routes/channels/#channel_id/messages/index.ts
index 1ae9d676..5fdab623 100644
--- a/api/src/routes/channels/#channel_id/messages/index.ts
+++ b/api/src/routes/channels/#channel_id/messages/index.ts
@@ -126,6 +126,13 @@ router.get("/", async (req: Request, res: Response) => {
 				y.proxy_url = `${endpoint == null ? "" : endpoint}${new URL(uri).pathname}`;
 			});
 
+			//Some clients ( discord.js ) only check if a property exists within the response,
+			//which causes erorrs when, say, the `application` property is `null`.
+			for (var curr in x) {
+				if (x[curr] === null)
+					delete x[curr];
+			}
+
 			return x;
 		})
 	);