UNPKG

enkanetwork

Version:

API wrapper for enka.network written on TypeScript which provides localization, caching and convenience

30 lines (29 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProfilePictureFinder = void 0; const errors_1 = require("../../errors"); class ProfilePictureFinder { data; localization; constructor(data, localization) { this.data = data; this.localization = localization; } // Searching for a **profile picture** by its id (ProfilePictureExcelConfigData id) getById(id) { const profilePicture = this.data.find((profilePicture) => profilePicture.id === id); if (!profilePicture) throw new errors_1.NoDataAssetsFound(`There is no profile picture with id = ${id}! (check the actuality of assets)`); return profilePicture; } getName(profilePicture, language) { const nameLocalization = this.localization[profilePicture.nameTextMapHash]; if (!nameLocalization) throw new errors_1.NoLocalizationAssetsFound(`There is no localization for profile picture with id = ${profilePicture.id}! (check the actuality of assets)`); const name = nameLocalization[language]; if (!name) throw new errors_1.NoLanguageFound("This language is not downloaded! Check the AssetsUpdater settings"); return name; } } exports.ProfilePictureFinder = ProfilePictureFinder;