Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually return error reason instead of lying about the user not exis…
Browse files Browse the repository at this point in the history
…ting
Regalijan authored Dec 13, 2024
1 parent 5019054 commit 86800d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/users/getPlayerInfo.js
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ function getPlayerInfo (userId) {
Promise.all(requests).then((promiseResponses) => {
const responses = promiseResponses.map(response => response.value)
const userBody = responses[0]
const failedResponse = promiseResponses.find(presponse => presponse.status === 'rejected') || responses.find(response => !response?.body || response.statusCode !== 200)
const failedResponses = promiseResponses.filter(presponse => presponse.status === 'rejected')

if (userBody.isBanned) {
const joinDate = new Date(userBody.created)
@@ -52,8 +52,8 @@ function getPlayerInfo (userId) {
isBanned,
displayName
})
} else if (failedResponse) {
reject(new Error('User does not exist.'))
} else if (failedResponses) {
reject(new Error(failedResponses.map(r => r.reason).join('\n')))
} else {
const responseBodies = responses.map(res => res.body ?? res)
const oldNames = responses[4].map(nameObject => nameObject.name) || []

0 comments on commit 86800d5

Please sign in to comment.