From 1d86692af09ffb9a41e59c3734dc728e783339f7 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Fri, 4 Feb 2022 19:59:13 +1100 Subject: [PATCH] Remove nulled properties from GET `/channels/#id/messages` for improved compatibility with some client ( discord.js ) --- api/src/routes/channels/#channel_id/messages/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) 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; }) );