Skip to content

Commit

Permalink
fix: await for imports.imgb64
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRoger committed Jun 14, 2024
1 parent 1de8d9f commit 7b852b4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions source/plugins/community/retroachievements/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default async function (
LastGameID: lastGameId,
},
} = profile;
const profilePic = imports.imgb64(`${retroachievementsUrl}${UserPic}`, {width: 64, height: 64})
const profilePic = await imports.imgb64(`${retroachievementsUrl}${UserPic}`, {width: 64, height: 64})

const lastPlayedGame = await imports.axios.get(
`https://retroachievements.org/API/API_GetGameInfoAndUserProgress.php?z=${username}&u=${target}&g=${lastGameId}&y=${token}`
Expand All @@ -44,7 +44,7 @@ export default async function (
UserCompletion: progress,
},
} = lastPlayedGame;
const gameIcon = imports.imgb64(`${retroachievementsUrl}${ImageIcon}`, {width: 64, height: 64})
const gameIcon = await imports.imgb64(`${retroachievementsUrl}${ImageIcon}`, {width: 64, height: 64})

let lastGameAchievements = null
if (showachievements) {
Expand All @@ -53,11 +53,12 @@ export default async function (
`https://retroachievements.org/API/API_GetUserRecentAchievements.php?z=${username}&y=${token}&u=${target}&m=${minutesToLookBack}`
);

lastGameAchievements = lastUnlocked.data.map(achievement => ({
let achievementsData = await Promise.all(lastUnlocked.data.map(async achievement => ({
title: achievement.Title,
description: achievement.Description,
badgeUrl: imports.imgb64(`${retroachievementsUrl}${achievement.BadgeURL}`, {width: 64, height: 64}),
})).slice(0, achievementslimit)
badgeUrl: await imports.imgb64(`${retroachievementsUrl}${achievement.BadgeURL}`, {width: 64, height: 64}),
})))
lastGameAchievements = achievementsData.slice(0, achievementslimit);
}

return {
Expand Down

0 comments on commit 7b852b4

Please sign in to comment.