From 19834d93f47f956a46fe2d096272a76888de80f1 Mon Sep 17 00:00:00 2001 From: Yann Le Vagueres Date: Fri, 16 Feb 2024 21:23:37 +0100 Subject: [PATCH] Fix authors in addon page --- .env.example | 1 + index.js | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 316ecaef..df19ae7e 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ PORT=8110 +BOT_API_TOKEN=123456789ABCDEFGH diff --git a/index.js b/index.js index 6c90c176..b1bbac9c 100644 --- a/index.js +++ b/index.js @@ -284,9 +284,10 @@ app.get("/addons/:name/?", (req, res, next) => { .then((res) => res.json()) .then(async (result) => { addon = result; - const res = await fetch(`https://api.faithfulpack.net/v2/users/raw`); - const users = await res.json(); - return Object.values(users).filter((user) => addon.authors.includes(user.id)); + const res = await fetch(`https://api.faithfulpack.net/v2/users/${addon.authors.join(',')}`); + const json_response = await res.json(); + + return Array.isArray(json_response) ? json_response : [json_response]; }) .then(async (result) => { const authors = result; @@ -301,9 +302,7 @@ app.get("/addons/:name/?", (req, res, next) => { return; } - const authorArray = addon.authors - .map((author) => authors[author]) - .filter((e) => !!e) + const authorArray = authors .map((user) => user.username) .filter((e) => !!e);