From 7894483f99150ff9a182295150a3bb0dee8886e4 Mon Sep 17 00:00:00 2001 From: Aiden Smith <80472468+aidendotgg@users.noreply.github.com> Date: Wed, 13 May 2026 05:58:54 -0400 Subject: [PATCH 1/3] Replace playerdb.co with mowojang.seraph.si --- utils/requests.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/utils/requests.js b/utils/requests.js index 0b95164..c4385b3 100644 --- a/utils/requests.js +++ b/utils/requests.js @@ -3,12 +3,12 @@ import fetch from 'node-fetch'; const key = process.env.HYPIXEL_SECRET_KEY export async function getMojang(slug) { - const response = await fetch(`https://playerdb.co/api/player/minecraft/${slug}`); + const response = await fetch(`https://mowojang.seraph.si/${slug}`); const json = await response.json(); return { response: response.status, - username: traverse(json, 'data.player.username'), - uuid: traverse(json, 'data.player.id'), + username: json.name, + uuid: normalizeUUID(json.id), }; } @@ -48,12 +48,9 @@ export async function getHypixelResource(endpoint) { } } -function traverse(json, path, defaultValue = undefined) { - const paths = path.split('.'); - for (const p of paths) { - if (json === undefined) return defaultValue; - json = json[p]; - } - if (json === undefined) return defaultValue; - return json; +function normalizeUUID(uuid) { + if (!uuid.includes("-")) { + return [uuid.slice(0, 8), uuid.slice(8, 12), uuid.slice(12, 16), uuid.slice(16, 20), uuid.slice(20)].join('-') + } + return uuid; } From 8aa48f18a35694eb607d51c5e8d621e14c4018a0 Mon Sep 17 00:00:00 2001 From: Aiden Smith <80472468+aidendotgg@users.noreply.github.com> Date: Wed, 13 May 2026 06:04:16 -0400 Subject: [PATCH 2/3] handle undefined values --- utils/requests.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/requests.js b/utils/requests.js index c4385b3..9a0970c 100644 --- a/utils/requests.js +++ b/utils/requests.js @@ -7,8 +7,8 @@ export async function getMojang(slug) { const json = await response.json(); return { response: response.status, - username: json.name, - uuid: normalizeUUID(json.id), + username: json?.name, + uuid: normalizeUUID(json?.id), }; } @@ -49,7 +49,7 @@ export async function getHypixelResource(endpoint) { } function normalizeUUID(uuid) { - if (!uuid.includes("-")) { + if (uuid && !uuid.includes("-")) { return [uuid.slice(0, 8), uuid.slice(8, 12), uuid.slice(12, 16), uuid.slice(16, 20), uuid.slice(20)].join('-') } return uuid; From 767ee290e647f18c686081ec3fa470bd9951208c Mon Sep 17 00:00:00 2001 From: Aiden Smith <80472468+aidendotgg@users.noreply.github.com> Date: Wed, 13 May 2026 06:16:11 -0400 Subject: [PATCH 3/3] Lower excessive cache TTL --- utils/caches.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/caches.js b/utils/caches.js index 4b46727..fef03bd 100644 --- a/utils/caches.js +++ b/utils/caches.js @@ -38,7 +38,7 @@ function getActiveClient(client, key) { client.set( key, Buffer.from(JSON.stringify(val)), - {expires: 30*24*60*60}); // If this changes, update the Tip.js file in 25Karma + {expires: 86400}); // If this changes, update the Tip.js file in 25Karma }, close: () => { client.close(); @@ -56,4 +56,4 @@ function getInactiveClient() { function sanitizeString(id) { return id.split('-').join('').toLowerCase(); -} \ No newline at end of file +}