hypixel-api-reborn 11.1.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +3 -3
- package/README.md +5 -3
- package/package.json +20 -18
- package/src/API/getAchievements.js +6 -0
- package/src/API/getChallenges.js +6 -0
- package/src/API/getGuild.js +1 -1
- package/src/API/getGuildAchievements.js +6 -0
- package/src/API/getLeaderboards.js +3 -1
- package/src/API/getPlayer.js +1 -1
- package/src/API/getQuests.js +6 -0
- package/src/API/getRecentGames.js +1 -1
- package/src/API/getServerInfo.js +3 -1
- package/src/API/getStatus.js +1 -1
- package/src/API/index.js +28 -17
- package/src/API/skyblock/getAuction.js +19 -0
- package/src/API/skyblock/{getSkyblockAuctions.js → getAuctions.js} +6 -2
- package/src/API/skyblock/{getSkyblockAuctionsByPlayer.js → getAuctionsByPlayer.js} +1 -1
- package/src/API/skyblock/getBingo.js +8 -0
- package/src/API/skyblock/getBingoByPlayer.js +14 -0
- package/src/API/skyblock/getFireSales.js +7 -0
- package/src/API/skyblock/getGovernment.js +8 -0
- package/src/API/skyblock/{getSkyblockMember.js → getMember.js} +9 -3
- package/src/API/skyblock/getMuseum.js +14 -0
- package/src/API/skyblock/{getSkyblockProfiles.js → getProfiles.js} +13 -7
- package/src/Client.js +88 -14
- package/src/Errors.js +38 -17
- package/src/Private/rateLimit.js +10 -2
- package/src/Private/requests.js +19 -7
- package/src/Private/updater.js +9 -5
- package/src/Private/uuidCache.js +23 -29
- package/src/Private/validate.js +20 -9
- package/src/index.js +9 -0
- package/src/structures/APIIncident.js +3 -9
- package/src/structures/Boosters/Booster.js +5 -5
- package/src/structures/Color.js +93 -48
- package/src/structures/Game.js +3 -1
- package/src/structures/Guild/Guild.js +21 -17
- package/src/structures/Guild/GuildMember.js +6 -6
- package/src/structures/Guild/GuildRank.js +2 -2
- package/src/structures/MiniGames/Arcade.js +22 -17
- package/src/structures/MiniGames/BedWars.js +152 -24
- package/src/structures/MiniGames/Duels.js +84 -23
- package/src/structures/MiniGames/MegaWalls.js +3 -1
- package/src/structures/MiniGames/MurderMystery.js +2 -2
- package/src/structures/MiniGames/Pit.js +231 -2
- package/src/structures/MiniGames/PitInventoryItem.js +43 -0
- package/src/structures/MiniGames/SkyWars.js +19 -14
- package/src/structures/MiniGames/SmashHeroes.js +1 -1
- package/src/structures/MiniGames/TNTGames.js +1 -1
- package/src/structures/MiniGames/UHC.js +21 -3
- package/src/structures/Player.js +16 -20
- package/src/structures/PlayerCosmetics.js +64 -10
- package/src/structures/ServerInfo.js +1 -1
- package/src/structures/SkyBlock/Auctions/Auction.js +3 -1
- package/src/structures/SkyBlock/Auctions/AuctionInfo.js +1 -0
- package/src/structures/SkyBlock/Auctions/BaseAuction.js +1 -0
- package/src/structures/SkyBlock/Auctions/Bid.js +1 -0
- package/src/structures/SkyBlock/Auctions/PartialAuction.js +1 -0
- package/src/structures/SkyBlock/PlayerBingo.js +56 -0
- package/src/structures/SkyBlock/SkyblockInventoryItem.js +86 -18
- package/src/structures/SkyBlock/SkyblockMember.js +252 -144
- package/src/structures/SkyBlock/SkyblockMuseum.js +60 -0
- package/src/structures/SkyBlock/SkyblockMuseumItem.js +54 -0
- package/src/structures/SkyBlock/SkyblockPet.js +1 -0
- package/src/structures/SkyBlock/SkyblockProfile.js +37 -23
- package/src/structures/SkyBlock/Static/Bingo.js +102 -0
- package/src/structures/SkyBlock/Static/BingoData.js +45 -0
- package/src/structures/SkyBlock/Static/Candidate.js +40 -0
- package/src/structures/SkyBlock/Static/FireSale.js +55 -0
- package/src/structures/SkyBlock/Static/Government.js +74 -0
- package/src/structures/SkyBlock/Static/Perk.js +24 -0
- package/src/structures/Static/Achievement.js +86 -0
- package/src/structures/Static/AchievementTier.js +33 -0
- package/src/structures/Static/Achievements.js +30 -0
- package/src/structures/Static/Challenges.js +29 -0
- package/src/structures/Static/GameAchievements.js +36 -0
- package/src/structures/Static/GameChallenges.js +40 -0
- package/src/structures/Static/GameQuests.js +24 -0
- package/src/structures/Static/GuildAchievements.js +34 -0
- package/src/structures/Static/Quest.js +66 -0
- package/src/structures/Static/Quests.js +31 -0
- package/src/structures/Status.js +2 -2
- package/src/utils/Constants.js +382 -41
- package/src/utils/SkyblockUtils.js +12 -7
- package/src/utils/guildExp.js +4 -1
- package/src/utils/removeSnakeCase.js +9 -2
- package/src/utils/romanize.js +32 -1
- package/src/utils/toIGN.js +6 -2
- package/src/utils/toUuid.js +10 -5
- package/typings/index.d.ts +985 -295
- /package/src/API/skyblock/{getSkyblockBazaar.js → getBazaar.js} +0 -0
- /package/src/API/skyblock/{getEndedSkyblockAuctions.js → getEndedAuctions.js} +0 -0
- /package/src/API/skyblock/{getSkyblockNews.js → getNews.js} +0 -0
package/src/Errors.js
CHANGED
|
@@ -2,44 +2,65 @@
|
|
|
2
2
|
module.exports = {
|
|
3
3
|
INVALID_API_KEY: '[hypixel-api-reborn] Invalid API Key! For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
4
4
|
NO_API_KEY: '[hypixel-api-reborn] No API Key specified! For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
5
|
-
ERROR_CODE_CAUSE:
|
|
5
|
+
ERROR_CODE_CAUSE:
|
|
6
|
+
'[hypixel-api-reborn] Code: {code} - {cause}! For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
6
7
|
ERROR_STATUSTEXT: '[hypixel-api-reborn] {statustext}! For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
7
|
-
KEY_MUST_BE_A_STRING:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
KEY_MUST_BE_A_STRING:
|
|
9
|
+
'[hypixel-api-reborn] Specified API Key must be a string! For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
10
|
+
OPTIONS_MUST_BE_AN_OBJECT:
|
|
11
|
+
'[hypixel-api-reborn] Options must be an object! For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
12
|
+
CACHE_TIME_MUST_BE_A_NUMBER:
|
|
13
|
+
'[hypixel-api-reborn] Cache Time must be a number! For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
14
|
+
CACHE_LIMIT_MUST_BE_A_NUMBER:
|
|
15
|
+
'[hypixel-api-reborn] Cache Limit must be a number! For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
16
|
+
CACHE_FILTER_INVALID:
|
|
17
|
+
'[hypixel-api-reborn] Cache Filter must be a function returning a boolean, an object, an array, or a string!',
|
|
12
18
|
NO_NICKNAME_UUID: '[hypixel-api-reborn] No nickname or uuid specified.',
|
|
13
19
|
NO_UUID: '[hypixel-api-reborn] No uuid specified.',
|
|
14
20
|
UUID_NICKNAME_MUST_BE_A_STRING: '[hypixel-api-reborn] Nickname or uuid must be a string.',
|
|
15
21
|
MALFORMED_UUID: '[hypixel-api-reborn] Malformed UUID!',
|
|
16
22
|
PLAYER_DOES_NOT_EXIST: '[hypixel-api-reborn] Player does not exist.',
|
|
17
23
|
PLAYER_HAS_NEVER_LOGGED: '[hypixel-api-reborn] Player has never logged into Hypixel.',
|
|
18
|
-
PLAYER_IS_INACTIVE:
|
|
24
|
+
PLAYER_IS_INACTIVE:
|
|
25
|
+
"[hypixel-api-reborn] No records of recent games because player hasn't been online for more than 3 days or is lacking data to determine the cause of an empty response",
|
|
19
26
|
PLAYER_DISABLED_ENDPOINT: '[hypixel-api-reborn] Player has disabled this endpoint.',
|
|
20
27
|
NO_GUILD_QUERY: '[hypixel-api-reborn] No guild search query specified.',
|
|
21
28
|
INVALID_GUILD_ID: '[hypixel-api-reborn] Specified Guild ID is invalid.',
|
|
22
29
|
INVALID_GUILD_SEARCH_PARAMETER: "[hypixel-api-reborn] getGuild() searchParameter must be 'id', 'guild' or 'player'.",
|
|
23
30
|
SOMETHING_WENT_WRONG: '[hypixel-api-reborn] Something went wrong. {cause}',
|
|
24
31
|
GUILD_DOES_NOT_EXIST: '[hypixel-api-reborn] Guild does not exist.',
|
|
25
|
-
PAGE_INDEX_ERROR:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
PAGE_INDEX_ERROR:
|
|
33
|
+
'[hypixel-api-reborn] Invalid page index. Must be an integer, an array of 2 integers, or a keyword. For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
34
|
+
INVALID_OPTION_VALUE:
|
|
35
|
+
'[hypixel-api-reborn] Invalid option value! For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
36
|
+
INVALID_RESPONSE_BODY:
|
|
37
|
+
'[hypixel-api-reborn] An error occurred while converting to JSON. Perhaps this is due to an update or maintenance. For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
38
|
+
INVALID_RATE_LIMIT_OPTION:
|
|
39
|
+
"[hypixel-api-reborn] Rate Limit provided in Client options must be 'HARD', 'AUTO', or 'NONE'. For help join our Discord Server https://discord.gg/NSEBNMM",
|
|
40
|
+
INVALID_KEY_LIMIT_OPTION:
|
|
41
|
+
'[hypixel-api-reborn] Key Limit provided in Client options must be an integer representing the amount of requests possible in one minute with your key.',
|
|
30
42
|
INVALID_HEADER_SYNC_OPTION: '[hypixel-api-reborn] Invalid Value for maxSyncHeaders : must be a boolean',
|
|
31
43
|
INVALID_BURST_OPTION: '[hypixel-api-reborn] maxBurstRequests provided in Client options must be a number',
|
|
32
|
-
NODE_VERSION_ERR:
|
|
44
|
+
NODE_VERSION_ERR:
|
|
45
|
+
"[hypixel-api-reborn] You are using a version of Nodejs that doesn't support certain features we use. Please upgrade to version 14 or above.",
|
|
33
46
|
UPDATER_REQUEST_NOT_OK: '[hypixel-api-reborn] An error occurred checking for updates.',
|
|
34
47
|
CONNECTION_ERROR: '[hypixel-api-reborn] Failed to connect.',
|
|
35
|
-
RATE_LIMIT_INIT_ERROR:
|
|
48
|
+
RATE_LIMIT_INIT_ERROR:
|
|
49
|
+
'[hypixel-api-reborn] An error happened whilst initializing rate limit. We strongly recommend restarting the code as this can lead to desynchronization.',
|
|
36
50
|
MULTIPLE_INSTANCES:
|
|
37
51
|
'[hypixel-api-reborn] Multiple instances of hypixel-api-reborn are found so we merged them for you. Please refrain from spawning multiple instances in the future. For more information, join our Discord Server https://discord.gg/NSEBNMM.',
|
|
38
|
-
INVALID_HEADERS:
|
|
39
|
-
|
|
52
|
+
INVALID_HEADERS:
|
|
53
|
+
'[hypixel-api-reborn] Invalid Headers are provided in ClientOptions. For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
54
|
+
INVALID_CACHE_HANDLER:
|
|
55
|
+
'[hypixel-api-reborn] An invalid cache handler is provideed. For help join our Discord Server https://discord.gg/NSEBNMM',
|
|
40
56
|
UNEXPECTED_ERROR:
|
|
41
57
|
"[hypixel-api-reborn] The data provided to hypixel API is malformed and thus not recognized by hypixel, but this shouldn't be your fault. Please report this error in our Discord Server https://discord.gg/NSEBNMM or GitHub. ",
|
|
42
58
|
RATE_LIMIT_EXCEEDED:
|
|
43
59
|
"[hypixel-api-reborn] The rate limitations on your API Key has been exceeded. There might be an outage (Check Hypixel's status page), or you simply did too many requests in a short time. Hint: Enable rate limit options! They can help you avoid this error! For help join our Discord Server https://discord.gg/NSEBNMM",
|
|
44
|
-
NO_SKYBLOCK_PROFILES: '[hypixel-api-reborn] The player has no skyblock profiles.'
|
|
60
|
+
NO_SKYBLOCK_PROFILES: '[hypixel-api-reborn] The player has no skyblock profiles.',
|
|
61
|
+
INVALID_SILENT_OPTION: '[hypixel-api-reborn] Invalid Value for silent : must be a boolean',
|
|
62
|
+
INVALID_UPDATE_OPTION: '[hypixel-api-reborn] Invalid Value for update : must be a boolean',
|
|
63
|
+
INVALID_THIRD_PARTY_API_OPTION: '[hypixel-api-reborn] Invalid Third Party API option : must be a boolean or string',
|
|
64
|
+
BAD_AUCTION_FILTER:
|
|
65
|
+
'[hypixel-api-reborn] Unexpected filter for Client#getSkyblockAuction. Expected one of "PLAYER", "AUCTION", "PROFILE", but got something else.'
|
|
45
66
|
};
|
package/src/Private/rateLimit.js
CHANGED
|
@@ -23,7 +23,11 @@ class RateLimit {
|
|
|
23
23
|
sync(data) {
|
|
24
24
|
this.options.keyLimit = parseInt(data.get('ratelimit-limit'), 10) || this.options.keyLimit;
|
|
25
25
|
this.requests = parseInt(data.get('ratelimit-remaining'), 10) || this.requests;
|
|
26
|
-
if (
|
|
26
|
+
if (
|
|
27
|
+
data.get('ratelimit-reset') &&
|
|
28
|
+
Math.round(Date.now() / 1000) - (300 - parseInt(data.get('ratelimit-reset'), 10)) !==
|
|
29
|
+
Math.round(this.lastResetHappenedAt / 1000)
|
|
30
|
+
) {
|
|
27
31
|
clearTimeout(this.resetTimer);
|
|
28
32
|
this.resetTimer = setTimeout(this.reset.bind(this), parseInt(data.get('ratelimit-reset'), 10) * 1000);
|
|
29
33
|
}
|
|
@@ -32,7 +36,11 @@ class RateLimit {
|
|
|
32
36
|
computeCooldownTime() {
|
|
33
37
|
const overhead = this.requestQueue[1] <= Date.now() ? 0 : this.requestQueue[1] - Date.now();
|
|
34
38
|
const multiplier = Math.floor(this.requests / this.options.keyLimit) + 1;
|
|
35
|
-
return
|
|
39
|
+
return (
|
|
40
|
+
overhead +
|
|
41
|
+
(-overhead - Date.now() + 300000 * multiplier + this.lastResetHappenedAt) /
|
|
42
|
+
(this.options.keyLimit * multiplier - this.requests)
|
|
43
|
+
);
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
reset() {
|
package/src/Private/requests.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable require-jsdoc */
|
|
2
2
|
const requireFetch = !globalThis.fetch;
|
|
3
|
-
const externalFetch =
|
|
3
|
+
const externalFetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
|
|
4
|
+
const fetch = requireFetch ? externalFetch : globalThis.fetch;
|
|
4
5
|
const BASE_URL = 'https://api.hypixel.net/v2';
|
|
5
6
|
const Errors = require('../Errors');
|
|
6
7
|
const Cache = require('./defaultCache');
|
|
@@ -14,16 +15,23 @@ class Requests {
|
|
|
14
15
|
}
|
|
15
16
|
async request(endpoint, options = {}) {
|
|
16
17
|
options.headers = { 'API-Key': this.client.key, ...options.headers };
|
|
17
|
-
const fetchMethod = requireFetch ? externalFetch : fetch;
|
|
18
18
|
/**
|
|
19
19
|
* @type {externalFetch.Response|Response}
|
|
20
20
|
*/
|
|
21
|
-
const res = await
|
|
22
|
-
if (res.status >= 500 && res.status < 528)
|
|
21
|
+
const res = await fetch(BASE_URL + endpoint, options);
|
|
22
|
+
if (res.status >= 500 && res.status < 528) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
Errors.ERROR_STATUSTEXT.replace(/{statustext}/, `Server Error : ${res.status} ${res.statusText}`)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
23
27
|
const parsedRes = await res.json().catch(() => {
|
|
24
28
|
throw new Error(Errors.INVALID_RESPONSE_BODY);
|
|
25
29
|
});
|
|
26
|
-
if (res.status === 400)
|
|
30
|
+
if (res.status === 400) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
Errors.ERROR_CODE_CAUSE.replace(/{code}/, '400 Bad Request').replace(/{cause}/, parsedRes.cause || '')
|
|
33
|
+
);
|
|
34
|
+
}
|
|
27
35
|
if (res.status === 403) throw new Error(Errors.INVALID_API_KEY);
|
|
28
36
|
if (res.status === 422) throw new Error(Errors.UNEXPECTED_ERROR);
|
|
29
37
|
if (res.status === 429) throw new Error(Errors.RATE_LIMIT_EXCEEDED);
|
|
@@ -36,10 +44,14 @@ class Requests {
|
|
|
36
44
|
if (options.noCaching) return parsedRes;
|
|
37
45
|
// split by question mark : first part is /path, remove /
|
|
38
46
|
if (this.client.options.cache && this.client.options.cacheFilter(endpoint.split('?')[0].slice(1))) {
|
|
39
|
-
if (this.client.options.cacheSize < (await this.cached.size()))
|
|
47
|
+
if (this.client.options.cacheSize < (await this.cached.size())) {
|
|
48
|
+
await this.cached.delete(Array.from(await this.cached.keys())[0]);
|
|
49
|
+
}
|
|
40
50
|
await this.cached.delete(endpoint);
|
|
41
51
|
await this.cached.set(endpoint, parsedRes);
|
|
42
|
-
if (this.client.options.
|
|
52
|
+
if (this.client.options.hypixelCacheTime >= 0) {
|
|
53
|
+
setTimeout(() => this.cached.delete(endpoint), 1000 * this.client.options.hypixelCacheTime);
|
|
54
|
+
}
|
|
43
55
|
}
|
|
44
56
|
return parsedRes;
|
|
45
57
|
}
|
package/src/Private/updater.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
/* eslint-disable require-jsdoc */
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
|
-
const
|
|
3
|
+
const requireFetch = !globalThis.fetch;
|
|
4
|
+
const externalFetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
|
|
5
|
+
const fetch = requireFetch ? externalFetch : globalThis.fetch;
|
|
4
6
|
const Errors = require('../Errors');
|
|
5
7
|
class Updater {
|
|
6
8
|
async checkForUpdates() {
|
|
7
|
-
const
|
|
9
|
+
const version = require('../../package.json').version;
|
|
8
10
|
const request = await fetch('https://registry.npmjs.org/hypixel-api-reborn');
|
|
9
11
|
if (!request.ok) return console.log(Errors.UPDATER_REQUEST_NOT_OK);
|
|
10
12
|
const metadata = await request.json();
|
|
11
|
-
const
|
|
12
|
-
const compare = this.compare(
|
|
13
|
+
const latest = metadata['dist-tags'].latest;
|
|
14
|
+
const compare = this.compare(version, latest);
|
|
13
15
|
if (compare === -1) {
|
|
14
|
-
console.log(
|
|
16
|
+
console.log(
|
|
17
|
+
`New version of hypixel-api-reborn is available! Current version: ${version}, Latest version: ${latest}`
|
|
18
|
+
);
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
compare(a, b) {
|
package/src/Private/uuidCache.js
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
/* eslint-disable require-jsdoc */
|
|
2
2
|
const requireFetch = !globalThis.fetch;
|
|
3
|
-
const externalFetch =
|
|
3
|
+
const externalFetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
|
|
4
4
|
const fetch = requireFetch ? externalFetch : globalThis.fetch;
|
|
5
|
-
const
|
|
5
|
+
const NodeCache = require('node-cache');
|
|
6
|
+
const cache = new NodeCache();
|
|
6
7
|
|
|
7
8
|
// TODO - use this for all cache models
|
|
8
9
|
|
|
9
|
-
async
|
|
10
|
-
|
|
11
|
-
response = await response.json();
|
|
12
|
-
cachedUuids.set(response.id, response.name);
|
|
13
|
-
setTimeout(deleteCache, 1000 * 60 * 10, response.id);
|
|
14
|
-
} catch (e) {
|
|
15
|
-
// F
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function deleteCache(id) {
|
|
19
|
-
return cachedUuids.delete(id);
|
|
20
|
-
}
|
|
21
|
-
function response(obj) {
|
|
22
|
-
return new fetch.Response(JSON.stringify(obj));
|
|
23
|
-
}
|
|
24
|
-
function checkHit(query) {
|
|
25
|
-
if (cachedUuids.has(query)) return response({ id: query, name: cachedUuids.get(query) });
|
|
26
|
-
const reverseSearch = Array.from(cachedUuids.entries()).find((pair) => pair[1].toLowerCase() === query.toLowerCase());
|
|
27
|
-
if (reverseSearch) return response({ id: reverseSearch[0], name: query });
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
module.exports = async (url, query) => {
|
|
31
|
-
if (checkHit(query || url)) return checkHit(query || url);
|
|
10
|
+
module.exports = async (url, query, cacheTime) => {
|
|
11
|
+
if (cache.has(query.toLowerCase())) return cache.get(query.toLowerCase());
|
|
32
12
|
const res = await fetch(url);
|
|
33
|
-
const
|
|
34
|
-
// Don't cache
|
|
35
|
-
if (
|
|
36
|
-
|
|
13
|
+
const data = await res.json();
|
|
14
|
+
// Don't cache 4xx
|
|
15
|
+
if (res.status >= 400) {
|
|
16
|
+
return {
|
|
17
|
+
status: res.status,
|
|
18
|
+
id: null,
|
|
19
|
+
name: null
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
cache.set(query.toLowerCase(), { status: res.status, id: data.id, name: data.name }, cacheTime);
|
|
24
|
+
cache.set(data.id.toLowerCase(), { status: res.status, id: data.id, name: data.name }, cacheTime);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
status: res.status,
|
|
28
|
+
id: data.id,
|
|
29
|
+
name: data.name
|
|
30
|
+
};
|
|
37
31
|
};
|
package/src/Private/validate.js
CHANGED
|
@@ -12,12 +12,20 @@ class Validation {
|
|
|
12
12
|
* @private
|
|
13
13
|
*/
|
|
14
14
|
validateOptions(options) {
|
|
15
|
-
if (typeof options.
|
|
15
|
+
if (typeof options.hypixelCacheTime !== 'number') throw new Error(Errors.CACHE_TIME_MUST_BE_A_NUMBER);
|
|
16
|
+
if (typeof options.mojangCacheTime !== 'number') throw new Error(Errors.CACHE_TIME_MUST_BE_A_NUMBER);
|
|
16
17
|
if (typeof options.cacheSize !== 'number') throw new Error(Errors.CACHE_LIMIT_MUST_BE_A_NUMBER);
|
|
17
|
-
if (typeof options.rateLimit !== 'string' || !['AUTO', 'HARD', 'NONE'].includes(options.rateLimit))
|
|
18
|
+
if (typeof options.rateLimit !== 'string' || !['AUTO', 'HARD', 'NONE'].includes(options.rateLimit)) {
|
|
19
|
+
throw new Error(Errors.INVALID_RATE_LIMIT_OPTION);
|
|
20
|
+
}
|
|
18
21
|
if (typeof options.keyLimit !== 'number') throw new Error(Errors.INVALID_KEY_LIMIT_OPTION);
|
|
19
22
|
if (typeof options.syncWithHeaders !== 'boolean') throw new Error(Errors.INVALID_HEADER_SYNC_OPTION);
|
|
20
23
|
if (typeof options.headers !== 'object') throw new Error(Errors.INVALID_HEADERS);
|
|
24
|
+
if (typeof options.silent !== 'boolean') throw new Error(Errors.INVALID_SILENT_OPTION);
|
|
25
|
+
if (typeof options.checkForUpdates !== 'boolean') throw new Error(Errors.INVALID_UPDATE_OPTION);
|
|
26
|
+
if (!['boolean', 'string'].includes(typeof options.useThirdPartyAPI)) {
|
|
27
|
+
throw new Error(Errors.INVALID_THIRD_PARTY_API_OPTION);
|
|
28
|
+
}
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
/**
|
|
@@ -29,16 +37,19 @@ class Validation {
|
|
|
29
37
|
parseOptions(options) {
|
|
30
38
|
if (typeof options !== 'object' || options === null) throw new Error(Errors.OPTIONS_MUST_BE_AN_OBJECT);
|
|
31
39
|
return {
|
|
32
|
-
cache: options.cache
|
|
33
|
-
|
|
40
|
+
cache: options.cache ?? true,
|
|
41
|
+
hypixelCacheTime: options.hypixelCacheTime ?? 60,
|
|
42
|
+
mojangCacheTime: options.mojangCacheTime ?? 600,
|
|
34
43
|
cacheSize: (options.cacheSize === -1 ? Infinity : options.cacheSize) || Infinity,
|
|
35
|
-
cacheFilter:
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
cacheFilter:
|
|
45
|
+
typeof options.cacheFilter === 'function' ? options.cacheFilter : this._handleFilter(options.cacheFilter),
|
|
46
|
+
rateLimit: options.rateLimit ?? 'AUTO',
|
|
47
|
+
keyLimit: options.keyLimit ?? 60,
|
|
38
48
|
syncWithHeaders: !!options.syncWithHeaders,
|
|
39
|
-
headers: options.headers
|
|
49
|
+
headers: options.headers ?? {},
|
|
40
50
|
silent: !!options.silent,
|
|
41
|
-
checkForUpdates: options.checkForUpdates
|
|
51
|
+
checkForUpdates: options.checkForUpdates ?? true,
|
|
52
|
+
useThirdPartyAPI: options.useThirdPartyAPI ?? false
|
|
42
53
|
};
|
|
43
54
|
}
|
|
44
55
|
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,10 @@ module.exports = {
|
|
|
14
14
|
Pets: require('./structures/Pets'),
|
|
15
15
|
PlayerCosmetics: require('./structures/PlayerCosmetics'),
|
|
16
16
|
|
|
17
|
+
/* Challenges */
|
|
18
|
+
Challenges: require('./structures/Static/Challenges.js'),
|
|
19
|
+
GameChallenges: require('./structures/Static/GameChallenges.js'),
|
|
20
|
+
|
|
17
21
|
/* Watchdog */
|
|
18
22
|
WatchdogStats: require('./structures/Watchdog/Stats.js'),
|
|
19
23
|
|
|
@@ -27,6 +31,10 @@ module.exports = {
|
|
|
27
31
|
SkyblockMember: require('./structures/SkyBlock/SkyblockMember.js'),
|
|
28
32
|
SkyblockInventoryItem: require('./structures/SkyBlock/SkyblockInventoryItem.js'),
|
|
29
33
|
SkyblockPet: require('./structures/SkyBlock/SkyblockPet'),
|
|
34
|
+
GovernmentData: require('./structures/SkyBlock/Static/Government.js'),
|
|
35
|
+
Candidate: require('./structures/SkyBlock/Static/Candidate.js'),
|
|
36
|
+
BingoData: require('./structures/SkyBlock/Static/BingoData.js'),
|
|
37
|
+
Bingo: require('./structures/SkyBlock/Static/Bingo.js'),
|
|
30
38
|
|
|
31
39
|
/* Skyblock Auctions */
|
|
32
40
|
BaseAuction: require('./structures/SkyBlock/Auctions/BaseAuction.js'),
|
|
@@ -34,6 +42,7 @@ module.exports = {
|
|
|
34
42
|
Auction: require('./structures/SkyBlock/Auctions/Auction.js'),
|
|
35
43
|
AuctionInfo: require('./structures/SkyBlock/Auctions/AuctionInfo.js'),
|
|
36
44
|
Bid: require('./structures/SkyBlock/Auctions/Bid.js'),
|
|
45
|
+
FireSale: require('./structures/SkyBlock/Static/FireSale.js'),
|
|
37
46
|
|
|
38
47
|
/* Skyblock Bazaar */
|
|
39
48
|
Product: require('./structures/SkyBlock/Bazzar/Product.js'),
|
|
@@ -42,12 +42,6 @@ class APIIncident {
|
|
|
42
42
|
* @type {string|null}
|
|
43
43
|
*/
|
|
44
44
|
this.snippet = data.contentSnippet || null;
|
|
45
|
-
/**
|
|
46
|
-
* Content as plain text
|
|
47
|
-
* The parsing might be faulty!
|
|
48
|
-
* @type {string|null}
|
|
49
|
-
*/
|
|
50
|
-
this.TextContent = (data.content || '').replace(/<[^>]+>/g, '') || null;
|
|
51
45
|
/**
|
|
52
46
|
* GUID
|
|
53
47
|
* @type {string|null}
|
|
@@ -64,14 +58,14 @@ class APIIncident {
|
|
|
64
58
|
* @type {boolean}
|
|
65
59
|
* @version >6.0.1
|
|
66
60
|
*/
|
|
67
|
-
this.isResolved = this.
|
|
61
|
+
this.isResolved = this.HTMLContent.includes('Resolved -') || this.HTMLContent.includes('Completed -');
|
|
68
62
|
}
|
|
69
63
|
/**
|
|
70
|
-
*
|
|
64
|
+
* HTML Content
|
|
71
65
|
* @return {string}
|
|
72
66
|
*/
|
|
73
67
|
toString() {
|
|
74
|
-
return this.
|
|
68
|
+
return this.HTMLContent;
|
|
75
69
|
}
|
|
76
70
|
}
|
|
77
71
|
|
|
@@ -9,27 +9,27 @@ class Booster {
|
|
|
9
9
|
constructor(data) {
|
|
10
10
|
/**
|
|
11
11
|
* Booster's purchaser's UUID
|
|
12
|
-
* @type {
|
|
12
|
+
* @type {string}
|
|
13
13
|
*/
|
|
14
14
|
this.purchaser = data.purchaserUuid;
|
|
15
15
|
/**
|
|
16
16
|
* Booster's multiplier
|
|
17
|
-
* @type {
|
|
17
|
+
* @type {number}
|
|
18
18
|
*/
|
|
19
19
|
this.amount = data.amount;
|
|
20
20
|
/**
|
|
21
21
|
* Booster's length in seconds
|
|
22
|
-
* @type {
|
|
22
|
+
* @type {number}
|
|
23
23
|
*/
|
|
24
24
|
this.originalLength = data.originalLength;
|
|
25
25
|
/**
|
|
26
26
|
* Length remaining in seconds
|
|
27
|
-
* @type {
|
|
27
|
+
* @type {number}
|
|
28
28
|
*/
|
|
29
29
|
this.remaining = data.length;
|
|
30
30
|
/**
|
|
31
31
|
* Date activated timestamp
|
|
32
|
-
* @type {
|
|
32
|
+
* @type {number}
|
|
33
33
|
*/
|
|
34
34
|
this.activatedTimestamp = data.dateActivated;
|
|
35
35
|
/**
|
package/src/structures/Color.js
CHANGED
|
@@ -68,62 +68,107 @@ class Color {
|
|
|
68
68
|
toCode() {
|
|
69
69
|
return this.color;
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Returns color code
|
|
74
|
+
* @return {InGameCode}
|
|
75
|
+
*/
|
|
76
|
+
toInGameCode() {
|
|
77
|
+
const InGameCodes = {
|
|
78
|
+
BLACK: '§0',
|
|
79
|
+
DARK_BLUE: '§1',
|
|
80
|
+
DARK_GREEN: '§2',
|
|
81
|
+
DARK_AQUA: '§3',
|
|
82
|
+
DARK_RED: '§4',
|
|
83
|
+
DARK_PURPLE: '§5',
|
|
84
|
+
GOLD: '§6',
|
|
85
|
+
GRAY: '§7',
|
|
86
|
+
DARK_GRAY: '§8',
|
|
87
|
+
BLUE: '§9',
|
|
88
|
+
GREEN: '§a',
|
|
89
|
+
AQUA: '§b',
|
|
90
|
+
RED: '§c',
|
|
91
|
+
LIGHT_PURPLE: '§d',
|
|
92
|
+
YELLOW: '§e',
|
|
93
|
+
WHITE: '§f'
|
|
94
|
+
};
|
|
95
|
+
return InGameCodes[this.color];
|
|
96
|
+
}
|
|
71
97
|
}
|
|
72
98
|
/**
|
|
73
99
|
* @typedef {string} ColorCode
|
|
74
|
-
* *
|
|
75
|
-
* *
|
|
76
|
-
* *
|
|
77
|
-
* *
|
|
78
|
-
* *
|
|
79
|
-
* *
|
|
80
|
-
* *
|
|
81
|
-
* *
|
|
82
|
-
* *
|
|
83
|
-
* *
|
|
84
|
-
* *
|
|
85
|
-
* *
|
|
86
|
-
* *
|
|
87
|
-
* *
|
|
88
|
-
* *
|
|
89
|
-
* *
|
|
100
|
+
* * 'BLACK'
|
|
101
|
+
* * 'DARK_BLUE'
|
|
102
|
+
* * 'DARK_GREEN'
|
|
103
|
+
* * 'DARK_AQUA'
|
|
104
|
+
* * 'DARK_RED'
|
|
105
|
+
* * 'DARK_PURPLE'
|
|
106
|
+
* * 'GOLD'
|
|
107
|
+
* * 'GRAY'
|
|
108
|
+
* * 'DARK_GRAY'
|
|
109
|
+
* * 'BLUE'
|
|
110
|
+
* * 'GREEN'
|
|
111
|
+
* * 'AQUA'
|
|
112
|
+
* * 'RED'
|
|
113
|
+
* * 'LIGHT_PURPLE'
|
|
114
|
+
* * 'YELLOW'
|
|
115
|
+
* * 'WHITE'
|
|
90
116
|
*/
|
|
91
117
|
/**
|
|
92
118
|
* @typedef {string} ColorString
|
|
93
|
-
* * BLACK:
|
|
94
|
-
* * DARK_BLUE:
|
|
95
|
-
* * DARK_GREEN:
|
|
96
|
-
* * DARK_AQUA:
|
|
97
|
-
* * DARK_RED:
|
|
98
|
-
* * DARK_PURPLE:
|
|
99
|
-
* * GOLD:
|
|
100
|
-
* * GRAY:
|
|
101
|
-
* * DARK_GRAY:
|
|
102
|
-
* * BLUE: `
|
|
103
|
-
* * GREEN:
|
|
104
|
-
* * AQUA:
|
|
105
|
-
* * RED:
|
|
106
|
-
* * LIGHT_PURPLE:
|
|
107
|
-
* * YELLOW:
|
|
108
|
-
* * WHITE:
|
|
119
|
+
* * BLACK: 'Black'
|
|
120
|
+
* * DARK_BLUE: 'Dark Blue'
|
|
121
|
+
* * DARK_GREEN: 'Dark Green'
|
|
122
|
+
* * DARK_AQUA: 'Dark Aqua'
|
|
123
|
+
* * DARK_RED: 'Dark Red'
|
|
124
|
+
* * DARK_PURPLE: 'Dark Purple'
|
|
125
|
+
* * GOLD: 'Gold'
|
|
126
|
+
* * GRAY: 'Gray'
|
|
127
|
+
* * DARK_GRAY: 'Dark Gray'
|
|
128
|
+
* * BLUE: 'Blue`'
|
|
129
|
+
* * GREEN: 'Green'
|
|
130
|
+
* * AQUA: 'Aqua'
|
|
131
|
+
* * RED: 'Red'
|
|
132
|
+
* * LIGHT_PURPLE: 'Light Purple'
|
|
133
|
+
* * YELLOW: 'Yellow'
|
|
134
|
+
* * WHITE: 'White'
|
|
109
135
|
*/
|
|
110
136
|
/**
|
|
111
137
|
* @typedef {string} ColorHex
|
|
112
|
-
* * BLACK:
|
|
113
|
-
* * DARK_BLUE:
|
|
114
|
-
* * DARK_GREEN:
|
|
115
|
-
* * DARK_AQUA:
|
|
116
|
-
* * DARK_RED:
|
|
117
|
-
* * DARK_PURPLE:
|
|
118
|
-
* * GOLD:
|
|
119
|
-
* * GRAY:
|
|
120
|
-
* * DARK_GRAY:
|
|
121
|
-
* * BLUE:
|
|
122
|
-
* * GREEN:
|
|
123
|
-
* * AQUA:
|
|
124
|
-
* * RED:
|
|
125
|
-
* * LIGHT_PURPLE:
|
|
126
|
-
* * YELLOW:
|
|
127
|
-
* * WHITE:
|
|
138
|
+
* * BLACK: '#000000'
|
|
139
|
+
* * DARK_BLUE: '#0000AA'
|
|
140
|
+
* * DARK_GREEN: '#008000'
|
|
141
|
+
* * DARK_AQUA: '#00AAAA'
|
|
142
|
+
* * DARK_RED: '#AA0000'
|
|
143
|
+
* * DARK_PURPLE: '#AA00AA'
|
|
144
|
+
* * GOLD: '#FFAA00'
|
|
145
|
+
* * GRAY: '#AAAAAA'
|
|
146
|
+
* * DARK_GRAY: '#555555'
|
|
147
|
+
* * BLUE: '#5555FF'
|
|
148
|
+
* * GREEN: '#3CE63C'
|
|
149
|
+
* * AQUA: '#3CE6E6'
|
|
150
|
+
* * RED: '#FF5555'
|
|
151
|
+
* * LIGHT_PURPLE: '#FF55FF'
|
|
152
|
+
* * YELLOW: '#FFFF55'
|
|
153
|
+
* * WHITE: '#FFFFFF'
|
|
154
|
+
*/
|
|
155
|
+
/**
|
|
156
|
+
* @typedef {string} InGameCode
|
|
157
|
+
* * BLACK: '§0'
|
|
158
|
+
* * DARK_BLUE: '§1'
|
|
159
|
+
* * DARK_GREEN: '§2'
|
|
160
|
+
* * DARK_AQUA: '§3'
|
|
161
|
+
* * DARK_RED: '§4'
|
|
162
|
+
* * DARK_PURPLE: '§5'
|
|
163
|
+
* * GOLD: '§6'
|
|
164
|
+
* * GRAY: '§7'
|
|
165
|
+
* * DARK_GRAY: '§8'
|
|
166
|
+
* * BLUE: '§9'
|
|
167
|
+
* * GREEN: '§a'
|
|
168
|
+
* * AQUA: '§b'
|
|
169
|
+
* * RED: '§c'
|
|
170
|
+
* * LIGHT_PURPLE: '§d'
|
|
171
|
+
* * YELLOW: '§e'
|
|
172
|
+
* * WHITE: '§f'
|
|
128
173
|
*/
|
|
129
174
|
module.exports = Color;
|
package/src/structures/Game.js
CHANGED
|
@@ -12,7 +12,9 @@ class Game {
|
|
|
12
12
|
* @type {GameId|GameCode}
|
|
13
13
|
*/
|
|
14
14
|
this.game = game.toString().toLowerCase();
|
|
15
|
-
const result = games.find(
|
|
15
|
+
const result = games.find(
|
|
16
|
+
(g) => g.code.toLowerCase() === this.game || g.id.toString() === this.game || g.name.toLowerCase() === this.game
|
|
17
|
+
);
|
|
16
18
|
/**
|
|
17
19
|
* ID of game
|
|
18
20
|
* @type {GameId}
|