aboutsummaryrefslogtreecommitdiff
path: root/build/hypixel.js
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-02-13 16:28:26 -0600
committermat <27899617+mat-1@users.noreply.github.com>2021-02-13 16:28:26 -0600
commit5c9ef89af1ee9af380ea82072a3a48d5db0f2c7a (patch)
tree8d3f2fc286a7f18931b1d561cf376b897e8f6d18 /build/hypixel.js
parentdd513537e240bbaf12c4f204d49db88111633d98 (diff)
downloadskyblock-api-5c9ef89af1ee9af380ea82072a3a48d5db0f2c7a.tar.gz
skyblock-api-5c9ef89af1ee9af380ea82072a3a48d5db0f2c7a.tar.bz2
skyblock-api-5c9ef89af1ee9af380ea82072a3a48d5db0f2c7a.zip
move some code to make more sense
Diffstat (limited to 'build/hypixel.js')
-rw-r--r--build/hypixel.js27
1 files changed, 26 insertions, 1 deletions
diff --git a/build/hypixel.js b/build/hypixel.js
index f651a66..847fbdb 100644
--- a/build/hypixel.js
+++ b/build/hypixel.js
@@ -22,7 +22,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
-exports.fetchUser = exports.sendCleanApiRequest = exports.maxMinion = exports.saveInterval = void 0;
+exports.fetchMemberProfile = exports.fetchUser = exports.sendCleanApiRequest = exports.maxMinion = exports.saveInterval = void 0;
const player_1 = require("./cleaners/player");
const hypixelApi_1 = require("./hypixelApi");
const cached = __importStar(require("./hypixelCached"));
@@ -108,3 +108,28 @@ async function fetchUser({ user, uuid, username }, included = ['player']) {
};
}
exports.fetchUser = fetchUser;
+/**
+ * Fetch a CleanMemberProfile from a user and string
+ * This is safe to use many times as the results are cached!
+ * @param user A username or uuid
+ * @param profile A profile name or profile uuid
+ */
+async function fetchMemberProfile(user, profile) {
+ const playerUuid = await cached.uuidFromUser(user);
+ const profileUuid = await cached.fetchProfileUuid(user, profile);
+ const player = await cached.fetchPlayer(playerUuid);
+ const cleanProfile = await cached.fetchProfile(playerUuid, profileUuid);
+ const member = cleanProfile.members.find(m => m.uuid === playerUuid);
+ return {
+ member: {
+ // the profile name is in member rather than profile since they sometimes differ for each member
+ profileName: cleanProfile.name,
+ // add all the member data
+ ...member,
+ // add all other data relating to the hypixel player, such as username, rank, etc
+ ...player
+ },
+ profile: cleanProfile
+ };
+}
+exports.fetchMemberProfile = fetchMemberProfile;