From a5bf9fc3295bf2de5dd7efc35f4442cfbf1576d3 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:50:56 -0400 Subject: [PATCH] We do a little API instability --- functions/api/game-bans/[user]/history.ts | 33 ++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/functions/api/game-bans/[user]/history.ts b/functions/api/game-bans/[user]/history.ts index a425ed7..3493998 100644 --- a/functions/api/game-bans/[user]/history.ts +++ b/functions/api/game-bans/[user]/history.ts @@ -26,14 +26,29 @@ export async function onRequestGet(context: RequestContext) { if (!users.length) return jsonError("No user found with that name", 400); - return jsonResponse( - JSON.stringify( - (await queryLogs(users[0].id, context)).sort((a, b) => - a.entity.properties.executed_at.integerValue > - b.entity.properties.executed_at.integerValue - ? 1 - : -1, - ), - ), + const thumbnailRequest = await fetch( + `https://thumbnails.roblox.com/v1/users/avatar?format=Png&size=250x250&userIds=${users[0].id}`, ); + + const response = { + history: (await queryLogs(users[0].id, context)).sort((a, b) => + a.entity.properties.executed_at.integerValue > + b.entity.properties.executed_at.integerValue + ? 1 + : -1, + ), + user: { + avatar: thumbnailRequest.ok + ? ( + (await thumbnailRequest.json()) as { + data: { imageUrl: string }[]; + } + ).data[0].imageUrl + : null, + id: users[0].id, + name: users[0].name, + }, + }; + + return jsonResponse(JSON.stringify(response)); }