hypixel-api-reborn 11.1.0 → 11.2.1
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 +6 -4
- package/eslint.config.mjs +71 -0
- package/package.json +21 -25
- package/src/API/getAchievements.js +7 -0
- package/src/API/getBoosters.js +1 -0
- package/src/API/getChallenges.js +7 -0
- package/src/API/getGameCounts.js +1 -0
- package/src/API/getGuild.js +5 -4
- package/src/API/getGuildAchievements.js +7 -0
- package/src/API/getLeaderboards.js +4 -2
- package/src/API/getPlayer.js +2 -1
- package/src/API/getQuests.js +7 -0
- package/src/API/getRecentGames.js +6 -10
- package/src/API/getServerInfo.js +42 -37
- package/src/API/getStatus.js +2 -1
- package/src/API/getWatchdogStats.js +1 -0
- package/src/API/index.js +28 -17
- package/src/API/skyblock/getAuction.js +21 -0
- package/src/API/skyblock/{getSkyblockAuctions.js → getAuctions.js} +19 -12
- package/src/API/skyblock/{getSkyblockAuctionsByPlayer.js → getAuctionsByPlayer.js} +2 -2
- package/src/API/skyblock/{getSkyblockBazaar.js → getBazaar.js} +1 -3
- package/src/API/skyblock/getBingo.js +7 -0
- package/src/API/skyblock/getBingoByPlayer.js +14 -0
- package/src/API/skyblock/{getEndedSkyblockAuctions.js → getEndedAuctions.js} +1 -0
- package/src/API/skyblock/getFireSales.js +7 -0
- package/src/API/skyblock/getGovernment.js +7 -0
- package/src/API/skyblock/{getSkyblockMember.js → getMember.js} +10 -3
- package/src/API/skyblock/getMuseum.js +15 -0
- package/src/API/skyblock/{getSkyblockNews.js → getNews.js} +1 -0
- package/src/API/skyblock/{getSkyblockProfiles.js → getProfiles.js} +14 -7
- package/src/Client.js +127 -25
- package/src/Errors.js +38 -17
- package/src/Private/rateLimit.js +17 -13
- package/src/Private/requests.js +27 -16
- package/src/Private/updater.js +11 -8
- package/src/Private/uuidCache.js +23 -30
- package/src/Private/validate.js +33 -22
- package/src/index.js +9 -0
- package/src/structures/APIIncident.js +4 -11
- package/src/structures/APIStatus.js +0 -1
- package/src/structures/Boosters/Booster.js +14 -13
- package/src/structures/Color.js +93 -48
- package/src/structures/Game.js +4 -2
- package/src/structures/Guild/Guild.js +35 -48
- package/src/structures/Guild/GuildMember.js +8 -8
- package/src/structures/Guild/GuildRank.js +2 -2
- package/src/structures/MiniGames/Arcade.js +242 -235
- package/src/structures/MiniGames/ArenaBrawl.js +11 -11
- package/src/structures/MiniGames/BedWars.js +262 -131
- package/src/structures/MiniGames/BlitzSurvivalGames.js +24 -23
- package/src/structures/MiniGames/CopsAndCrims.js +1 -0
- package/src/structures/MiniGames/Duels.js +92 -33
- package/src/structures/MiniGames/MegaWalls.js +3 -1
- package/src/structures/MiniGames/MurderMystery.js +2 -2
- package/src/structures/MiniGames/Pit.js +230 -2
- package/src/structures/MiniGames/PitInventoryItem.js +43 -0
- package/src/structures/MiniGames/SkyWars.js +211 -195
- package/src/structures/MiniGames/SmashHeroes.js +37 -35
- package/src/structures/MiniGames/SpeedUHC.js +17 -4
- package/src/structures/MiniGames/TNTGames.js +1 -1
- package/src/structures/MiniGames/UHC.js +33 -14
- package/src/structures/MiniGames/WoolWars.js +6 -5
- package/src/structures/Pet.js +1 -1
- package/src/structures/Player.js +26 -121
- package/src/structures/PlayerCosmetics.js +67 -12
- package/src/structures/ServerInfo.js +1 -1
- package/src/structures/SkyBlock/Auctions/Auction.js +3 -1
- package/src/structures/SkyBlock/Auctions/AuctionInfo.js +3 -1
- package/src/structures/SkyBlock/Auctions/BaseAuction.js +2 -1
- package/src/structures/SkyBlock/Auctions/Bid.js +1 -0
- package/src/structures/SkyBlock/Auctions/PartialAuction.js +1 -0
- package/src/structures/SkyBlock/News/SkyblockNews.js +15 -15
- package/src/structures/SkyBlock/PlayerBingo.js +49 -0
- package/src/structures/SkyBlock/SkyblockInventoryItem.js +76 -32
- package/src/structures/SkyBlock/SkyblockMember.js +252 -289
- package/src/structures/SkyBlock/SkyblockMuseum.js +60 -0
- package/src/structures/SkyBlock/SkyblockMuseumItem.js +54 -0
- package/src/structures/SkyBlock/SkyblockPet.js +3 -3
- package/src/structures/SkyBlock/SkyblockProfile.js +37 -23
- package/src/structures/SkyBlock/Static/Bingo.js +101 -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 +87 -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 +384 -543
- package/src/utils/{guildExp.js → Guild.js} +46 -13
- package/src/utils/Player.js +112 -0
- package/src/utils/SkyblockUtils.js +448 -186
- package/src/utils/arrayTools.js +1 -1
- package/src/utils/divide.js +1 -1
- package/src/utils/index.js +2 -1
- package/src/utils/isGuildID.js +1 -1
- package/src/utils/oscillation.js +4 -2
- package/src/utils/removeSnakeCase.js +19 -8
- package/src/utils/rgbToHexColor.js +1 -1
- package/src/utils/romanize.js +35 -4
- package/src/utils/toUuid.js +12 -7
- package/src/utils/varInt.js +2 -2
- package/typings/index.d.ts +1246 -446
- package/src/utils/toIGN.js +0 -20
package/src/Private/updater.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
/* eslint-disable require-jsdoc */
|
|
2
1
|
/* eslint-disable no-console */
|
|
3
|
-
const
|
|
2
|
+
const requireFetch = !globalThis.fetch;
|
|
3
|
+
const externalFetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
|
|
4
|
+
const fetch = requireFetch ? externalFetch : globalThis.fetch;
|
|
4
5
|
const Errors = require('../Errors');
|
|
5
6
|
class Updater {
|
|
6
7
|
async checkForUpdates() {
|
|
7
|
-
const
|
|
8
|
+
const version = require('../../package.json').version;
|
|
8
9
|
const request = await fetch('https://registry.npmjs.org/hypixel-api-reborn');
|
|
9
10
|
if (!request.ok) return console.log(Errors.UPDATER_REQUEST_NOT_OK);
|
|
10
11
|
const metadata = await request.json();
|
|
11
|
-
const
|
|
12
|
-
const compare = this.compare(
|
|
13
|
-
if (
|
|
14
|
-
console.log(
|
|
12
|
+
const latest = metadata['dist-tags'].latest;
|
|
13
|
+
const compare = this.compare(version, latest);
|
|
14
|
+
if (-1 === compare) {
|
|
15
|
+
console.log(
|
|
16
|
+
`New version of hypixel-api-reborn is available! Current version: ${version}, Latest version: ${latest}`
|
|
17
|
+
);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
compare(a, b) {
|
|
18
21
|
const pa = a.split('.');
|
|
19
22
|
const pb = b.split('.');
|
|
20
|
-
for (let i = 0;
|
|
23
|
+
for (let i = 0; 3 > i; i++) {
|
|
21
24
|
const na = Number(pa[i]);
|
|
22
25
|
const nb = Number(pb[i]);
|
|
23
26
|
if (na > nb) return 1;
|
package/src/Private/uuidCache.js
CHANGED
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
/* eslint-disable require-jsdoc */
|
|
2
1
|
const requireFetch = !globalThis.fetch;
|
|
3
|
-
const externalFetch =
|
|
2
|
+
const externalFetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
|
|
4
3
|
const fetch = requireFetch ? externalFetch : globalThis.fetch;
|
|
5
|
-
const
|
|
4
|
+
const NodeCache = require('node-cache');
|
|
5
|
+
const cache = new NodeCache();
|
|
6
6
|
|
|
7
7
|
// TODO - use this for all cache models
|
|
8
8
|
|
|
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);
|
|
9
|
+
module.exports = async (url, query, cacheTime) => {
|
|
10
|
+
if (cache.has(query.toLowerCase())) return cache.get(query.toLowerCase());
|
|
32
11
|
const res = await fetch(url);
|
|
33
|
-
const
|
|
34
|
-
// Don't cache
|
|
35
|
-
if (
|
|
36
|
-
|
|
12
|
+
const data = await res.json();
|
|
13
|
+
// Don't cache 4xx
|
|
14
|
+
if (400 <= res.status) {
|
|
15
|
+
return {
|
|
16
|
+
status: res.status,
|
|
17
|
+
id: null,
|
|
18
|
+
name: null
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
cache.set(query.toLowerCase(), { status: res.status, id: data.id, name: data.name }, cacheTime);
|
|
23
|
+
cache.set(data.id.toLowerCase(), { status: res.status, id: data.id, name: data.name }, cacheTime);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
status: res.status,
|
|
27
|
+
id: data.id,
|
|
28
|
+
name: data.name
|
|
29
|
+
};
|
|
37
30
|
};
|
package/src/Private/validate.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable require-jsdoc */
|
|
2
1
|
const Errors = require('../Errors');
|
|
3
2
|
const { isStrArray, strToArray } = require('../utils/arrayTools');
|
|
4
3
|
/**
|
|
@@ -12,12 +11,20 @@ class Validation {
|
|
|
12
11
|
* @private
|
|
13
12
|
*/
|
|
14
13
|
validateOptions(options) {
|
|
15
|
-
if (typeof options.
|
|
16
|
-
if (typeof options.
|
|
17
|
-
if (
|
|
18
|
-
if (typeof options.
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if ('number' !== typeof options.hypixelCacheTime) throw new Error(Errors.CACHE_TIME_MUST_BE_A_NUMBER);
|
|
15
|
+
if ('number' !== typeof options.mojangCacheTime) throw new Error(Errors.CACHE_TIME_MUST_BE_A_NUMBER);
|
|
16
|
+
if ('number' !== typeof options.cacheSize) throw new Error(Errors.CACHE_LIMIT_MUST_BE_A_NUMBER);
|
|
17
|
+
if ('string' !== typeof options.rateLimit || !['AUTO', 'HARD', 'NONE'].includes(options.rateLimit)) {
|
|
18
|
+
throw new Error(Errors.INVALID_RATE_LIMIT_OPTION);
|
|
19
|
+
}
|
|
20
|
+
if ('number' !== typeof options.keyLimit) throw new Error(Errors.INVALID_KEY_LIMIT_OPTION);
|
|
21
|
+
if ('boolean' !== typeof options.syncWithHeaders) throw new Error(Errors.INVALID_HEADER_SYNC_OPTION);
|
|
22
|
+
if ('object' !== typeof options.headers) throw new Error(Errors.INVALID_HEADERS);
|
|
23
|
+
if ('boolean' !== typeof options.silent) throw new Error(Errors.INVALID_SILENT_OPTION);
|
|
24
|
+
if ('boolean' !== typeof options.checkForUpdates) throw new Error(Errors.INVALID_UPDATE_OPTION);
|
|
25
|
+
if (!['boolean', 'string'].includes(typeof options.useThirdPartyAPI)) {
|
|
26
|
+
throw new Error(Errors.INVALID_THIRD_PARTY_API_OPTION);
|
|
27
|
+
}
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
/**
|
|
@@ -27,18 +34,22 @@ class Validation {
|
|
|
27
34
|
* @private
|
|
28
35
|
*/
|
|
29
36
|
parseOptions(options) {
|
|
30
|
-
if (
|
|
37
|
+
if ('object' !== typeof options || null === options) throw new Error(Errors.OPTIONS_MUST_BE_AN_OBJECT);
|
|
31
38
|
return {
|
|
32
|
-
cache: options.cache
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
cache: options.cache ?? true,
|
|
40
|
+
hypixelCacheTime: options.hypixelCacheTime ?? 60,
|
|
41
|
+
mojangCacheTime: options.mojangCacheTime ?? 600,
|
|
42
|
+
cacheSize: (-1 === options.cacheSize ? Infinity : options.cacheSize) || Infinity,
|
|
43
|
+
cacheFilter:
|
|
44
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
45
|
+
'function' === typeof options.cacheFilter ? options.cacheFilter : this._handleFilter(options.cacheFilter),
|
|
46
|
+
rateLimit: options.rateLimit ?? 'AUTO',
|
|
47
|
+
keyLimit: options.keyLimit ?? 60,
|
|
48
|
+
syncWithHeaders: Boolean(options.syncWithHeaders),
|
|
49
|
+
headers: options.headers ?? {},
|
|
50
|
+
silent: Boolean(options.silent),
|
|
51
|
+
checkForUpdates: options.checkForUpdates ?? true,
|
|
52
|
+
useThirdPartyAPI: options.useThirdPartyAPI ?? false
|
|
42
53
|
};
|
|
43
54
|
}
|
|
44
55
|
|
|
@@ -50,7 +61,7 @@ class Validation {
|
|
|
50
61
|
*/
|
|
51
62
|
validateKey(key) {
|
|
52
63
|
if (!key) throw new Error(Errors.NO_API_KEY);
|
|
53
|
-
if (typeof key
|
|
64
|
+
if ('string' !== typeof key) throw new Error(Errors.KEY_MUST_BE_A_STRING);
|
|
54
65
|
return key;
|
|
55
66
|
}
|
|
56
67
|
|
|
@@ -61,7 +72,7 @@ class Validation {
|
|
|
61
72
|
* @private
|
|
62
73
|
*/
|
|
63
74
|
cacheSuboptions(input) {
|
|
64
|
-
if (
|
|
75
|
+
if ('object' !== typeof input || null === input) return false;
|
|
65
76
|
if (!input.noCacheCheck && !input.noCaching && !input.raw) return false;
|
|
66
77
|
return true;
|
|
67
78
|
}
|
|
@@ -74,7 +85,7 @@ class Validation {
|
|
|
74
85
|
*/
|
|
75
86
|
_handleFilter(filter) {
|
|
76
87
|
if (!filter) return () => true;
|
|
77
|
-
if (typeof filter
|
|
88
|
+
if ('object' === typeof filter && !Array.isArray(filter)) {
|
|
78
89
|
if (filter.whitelist && isStrArray(filter.whitelist)) return (x) => strToArray(filter.whitelist).includes(x);
|
|
79
90
|
if (filter.blacklist && isStrArray(filter.blacklist)) return (x) => !strToArray(filter.blacklist).includes(x);
|
|
80
91
|
throw new Error(Errors.CACHE_FILTER_INVALID);
|
|
@@ -91,7 +102,7 @@ class Validation {
|
|
|
91
102
|
*/
|
|
92
103
|
validateNodeVersion() {
|
|
93
104
|
const nodeVersion = parseInt(process.version.match(/v(\d{2})\.\d{1,}\.\d+/)[1], 10);
|
|
94
|
-
if (
|
|
105
|
+
if (12 > nodeVersion) throw new Error(Errors.NODE_VERSION_ERR);
|
|
95
106
|
}
|
|
96
107
|
}
|
|
97
108
|
module.exports = Validation;
|
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'),
|
|
@@ -16,7 +16,7 @@ class APIIncident {
|
|
|
16
16
|
* Timestamp when investigation was started as Date object
|
|
17
17
|
* @type {object|null}
|
|
18
18
|
*/
|
|
19
|
-
this.start = new Date(data.pubDate)
|
|
19
|
+
this.start = data.pubDate ? new Date(data.pubDate) : null;
|
|
20
20
|
/**
|
|
21
21
|
* Formatted timestamp when investigation was started
|
|
22
22
|
* @type {string|null}
|
|
@@ -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}
|
|
@@ -62,16 +56,15 @@ class APIIncident {
|
|
|
62
56
|
* Whether the incident is resolved/completed or not
|
|
63
57
|
* @author linearaccelerator
|
|
64
58
|
* @type {boolean}
|
|
65
|
-
* @version >6.0.1
|
|
66
59
|
*/
|
|
67
|
-
this.isResolved = this.
|
|
60
|
+
this.isResolved = this.HTMLContent.includes('Resolved -') || this.HTMLContent.includes('Completed -');
|
|
68
61
|
}
|
|
69
62
|
/**
|
|
70
|
-
*
|
|
63
|
+
* HTML Content
|
|
71
64
|
* @return {string}
|
|
72
65
|
*/
|
|
73
66
|
toString() {
|
|
74
|
-
return this.
|
|
67
|
+
return this.HTMLContent;
|
|
75
68
|
}
|
|
76
69
|
}
|
|
77
70
|
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
const Game = require('../Game');
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
4
|
+
function parseType(data) {
|
|
5
|
+
if (true === data.stacked) return 'STACKED';
|
|
6
|
+
if (!data.stacked) return 'QUEUED';
|
|
7
|
+
return 'ACTIVE';
|
|
8
|
+
}
|
|
9
|
+
|
|
2
10
|
/**
|
|
3
11
|
* Booster class
|
|
4
12
|
*/
|
|
@@ -9,27 +17,27 @@ class Booster {
|
|
|
9
17
|
constructor(data) {
|
|
10
18
|
/**
|
|
11
19
|
* Booster's purchaser's UUID
|
|
12
|
-
* @type {
|
|
20
|
+
* @type {string}
|
|
13
21
|
*/
|
|
14
22
|
this.purchaser = data.purchaserUuid;
|
|
15
23
|
/**
|
|
16
24
|
* Booster's multiplier
|
|
17
|
-
* @type {
|
|
25
|
+
* @type {number}
|
|
18
26
|
*/
|
|
19
27
|
this.amount = data.amount;
|
|
20
28
|
/**
|
|
21
29
|
* Booster's length in seconds
|
|
22
|
-
* @type {
|
|
30
|
+
* @type {number}
|
|
23
31
|
*/
|
|
24
32
|
this.originalLength = data.originalLength;
|
|
25
33
|
/**
|
|
26
34
|
* Length remaining in seconds
|
|
27
|
-
* @type {
|
|
35
|
+
* @type {number}
|
|
28
36
|
*/
|
|
29
37
|
this.remaining = data.length;
|
|
30
38
|
/**
|
|
31
39
|
* Date activated timestamp
|
|
32
|
-
* @type {
|
|
40
|
+
* @type {number}
|
|
33
41
|
*/
|
|
34
42
|
this.activatedTimestamp = data.dateActivated;
|
|
35
43
|
/**
|
|
@@ -63,7 +71,7 @@ class Booster {
|
|
|
63
71
|
* Works by checking if date.length is negative
|
|
64
72
|
* @type {boolean}
|
|
65
73
|
*/
|
|
66
|
-
this.expired = data.length
|
|
74
|
+
this.expired = 0 > data.length;
|
|
67
75
|
}
|
|
68
76
|
/**
|
|
69
77
|
* Beautiful format
|
|
@@ -73,11 +81,4 @@ class Booster {
|
|
|
73
81
|
return `${this.purchaser}'s booster in ${this.game}`;
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
|
-
|
|
77
|
-
// eslint-disable-next-line require-jsdoc
|
|
78
|
-
function parseType(data) {
|
|
79
|
-
if (data.stacked === true) return 'STACKED';
|
|
80
|
-
if (!data.stacked) return 'QUEUED';
|
|
81
|
-
return 'ACTIVE';
|
|
82
|
-
}
|
|
83
84
|
module.exports = Booster;
|
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}
|
|
@@ -32,7 +34,7 @@ class Game {
|
|
|
32
34
|
* Whether the game is found
|
|
33
35
|
* @type {boolean}
|
|
34
36
|
*/
|
|
35
|
-
this.found =
|
|
37
|
+
this.found = Boolean(result);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
/**
|