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.
Files changed (113) hide show
  1. package/.prettierrc +3 -3
  2. package/README.md +6 -4
  3. package/eslint.config.mjs +71 -0
  4. package/package.json +21 -25
  5. package/src/API/getAchievements.js +7 -0
  6. package/src/API/getBoosters.js +1 -0
  7. package/src/API/getChallenges.js +7 -0
  8. package/src/API/getGameCounts.js +1 -0
  9. package/src/API/getGuild.js +5 -4
  10. package/src/API/getGuildAchievements.js +7 -0
  11. package/src/API/getLeaderboards.js +4 -2
  12. package/src/API/getPlayer.js +2 -1
  13. package/src/API/getQuests.js +7 -0
  14. package/src/API/getRecentGames.js +6 -10
  15. package/src/API/getServerInfo.js +42 -37
  16. package/src/API/getStatus.js +2 -1
  17. package/src/API/getWatchdogStats.js +1 -0
  18. package/src/API/index.js +28 -17
  19. package/src/API/skyblock/getAuction.js +21 -0
  20. package/src/API/skyblock/{getSkyblockAuctions.js → getAuctions.js} +19 -12
  21. package/src/API/skyblock/{getSkyblockAuctionsByPlayer.js → getAuctionsByPlayer.js} +2 -2
  22. package/src/API/skyblock/{getSkyblockBazaar.js → getBazaar.js} +1 -3
  23. package/src/API/skyblock/getBingo.js +7 -0
  24. package/src/API/skyblock/getBingoByPlayer.js +14 -0
  25. package/src/API/skyblock/{getEndedSkyblockAuctions.js → getEndedAuctions.js} +1 -0
  26. package/src/API/skyblock/getFireSales.js +7 -0
  27. package/src/API/skyblock/getGovernment.js +7 -0
  28. package/src/API/skyblock/{getSkyblockMember.js → getMember.js} +10 -3
  29. package/src/API/skyblock/getMuseum.js +15 -0
  30. package/src/API/skyblock/{getSkyblockNews.js → getNews.js} +1 -0
  31. package/src/API/skyblock/{getSkyblockProfiles.js → getProfiles.js} +14 -7
  32. package/src/Client.js +127 -25
  33. package/src/Errors.js +38 -17
  34. package/src/Private/rateLimit.js +17 -13
  35. package/src/Private/requests.js +27 -16
  36. package/src/Private/updater.js +11 -8
  37. package/src/Private/uuidCache.js +23 -30
  38. package/src/Private/validate.js +33 -22
  39. package/src/index.js +9 -0
  40. package/src/structures/APIIncident.js +4 -11
  41. package/src/structures/APIStatus.js +0 -1
  42. package/src/structures/Boosters/Booster.js +14 -13
  43. package/src/structures/Color.js +93 -48
  44. package/src/structures/Game.js +4 -2
  45. package/src/structures/Guild/Guild.js +35 -48
  46. package/src/structures/Guild/GuildMember.js +8 -8
  47. package/src/structures/Guild/GuildRank.js +2 -2
  48. package/src/structures/MiniGames/Arcade.js +242 -235
  49. package/src/structures/MiniGames/ArenaBrawl.js +11 -11
  50. package/src/structures/MiniGames/BedWars.js +262 -131
  51. package/src/structures/MiniGames/BlitzSurvivalGames.js +24 -23
  52. package/src/structures/MiniGames/CopsAndCrims.js +1 -0
  53. package/src/structures/MiniGames/Duels.js +92 -33
  54. package/src/structures/MiniGames/MegaWalls.js +3 -1
  55. package/src/structures/MiniGames/MurderMystery.js +2 -2
  56. package/src/structures/MiniGames/Pit.js +230 -2
  57. package/src/structures/MiniGames/PitInventoryItem.js +43 -0
  58. package/src/structures/MiniGames/SkyWars.js +211 -195
  59. package/src/structures/MiniGames/SmashHeroes.js +37 -35
  60. package/src/structures/MiniGames/SpeedUHC.js +17 -4
  61. package/src/structures/MiniGames/TNTGames.js +1 -1
  62. package/src/structures/MiniGames/UHC.js +33 -14
  63. package/src/structures/MiniGames/WoolWars.js +6 -5
  64. package/src/structures/Pet.js +1 -1
  65. package/src/structures/Player.js +26 -121
  66. package/src/structures/PlayerCosmetics.js +67 -12
  67. package/src/structures/ServerInfo.js +1 -1
  68. package/src/structures/SkyBlock/Auctions/Auction.js +3 -1
  69. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +3 -1
  70. package/src/structures/SkyBlock/Auctions/BaseAuction.js +2 -1
  71. package/src/structures/SkyBlock/Auctions/Bid.js +1 -0
  72. package/src/structures/SkyBlock/Auctions/PartialAuction.js +1 -0
  73. package/src/structures/SkyBlock/News/SkyblockNews.js +15 -15
  74. package/src/structures/SkyBlock/PlayerBingo.js +49 -0
  75. package/src/structures/SkyBlock/SkyblockInventoryItem.js +76 -32
  76. package/src/structures/SkyBlock/SkyblockMember.js +252 -289
  77. package/src/structures/SkyBlock/SkyblockMuseum.js +60 -0
  78. package/src/structures/SkyBlock/SkyblockMuseumItem.js +54 -0
  79. package/src/structures/SkyBlock/SkyblockPet.js +3 -3
  80. package/src/structures/SkyBlock/SkyblockProfile.js +37 -23
  81. package/src/structures/SkyBlock/Static/Bingo.js +101 -0
  82. package/src/structures/SkyBlock/Static/BingoData.js +45 -0
  83. package/src/structures/SkyBlock/Static/Candidate.js +40 -0
  84. package/src/structures/SkyBlock/Static/FireSale.js +55 -0
  85. package/src/structures/SkyBlock/Static/Government.js +74 -0
  86. package/src/structures/SkyBlock/Static/Perk.js +24 -0
  87. package/src/structures/Static/Achievement.js +87 -0
  88. package/src/structures/Static/AchievementTier.js +33 -0
  89. package/src/structures/Static/Achievements.js +30 -0
  90. package/src/structures/Static/Challenges.js +29 -0
  91. package/src/structures/Static/GameAchievements.js +36 -0
  92. package/src/structures/Static/GameChallenges.js +40 -0
  93. package/src/structures/Static/GameQuests.js +24 -0
  94. package/src/structures/Static/GuildAchievements.js +34 -0
  95. package/src/structures/Static/Quest.js +66 -0
  96. package/src/structures/Static/Quests.js +31 -0
  97. package/src/structures/Status.js +2 -2
  98. package/src/utils/Constants.js +384 -543
  99. package/src/utils/{guildExp.js → Guild.js} +46 -13
  100. package/src/utils/Player.js +112 -0
  101. package/src/utils/SkyblockUtils.js +448 -186
  102. package/src/utils/arrayTools.js +1 -1
  103. package/src/utils/divide.js +1 -1
  104. package/src/utils/index.js +2 -1
  105. package/src/utils/isGuildID.js +1 -1
  106. package/src/utils/oscillation.js +4 -2
  107. package/src/utils/removeSnakeCase.js +19 -8
  108. package/src/utils/rgbToHexColor.js +1 -1
  109. package/src/utils/romanize.js +35 -4
  110. package/src/utils/toUuid.js +12 -7
  111. package/src/utils/varInt.js +2 -2
  112. package/typings/index.d.ts +1246 -446
  113. package/src/utils/toIGN.js +0 -20
@@ -1,23 +1,26 @@
1
- /* eslint-disable require-jsdoc */
2
1
  /* eslint-disable no-console */
3
- const fetch = require('node-fetch');
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 currentVersion = require('../../package.json').version;
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 latestVersion = metadata['dist-tags'].latest;
12
- const compare = this.compare(currentVersion, latestVersion);
13
- if (compare === -1) {
14
- console.log(`New version of hypixel-api-reborn is available! Current version: ${currentVersion}, Latest version: ${latestVersion}`);
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; i < 3; i++) {
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;
@@ -1,37 +1,30 @@
1
- /* eslint-disable require-jsdoc */
2
1
  const requireFetch = !globalThis.fetch;
3
- const externalFetch = require('node-fetch');
2
+ const externalFetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
4
3
  const fetch = requireFetch ? externalFetch : globalThis.fetch;
5
- const cachedUuids = new Map();
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 function putCache(response) {
10
- try {
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 response = await res.clone().json();
34
- // Don't cache 5xx
35
- if (response.error !== 'Internal Server Error' && response.status < 500) setTimeout(putCache, 0, res.clone());
36
- return res;
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
  };
@@ -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.cacheTime !== 'number') throw new Error(Errors.CACHE_TIME_MUST_BE_A_NUMBER);
16
- 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)) throw new Error(Errors.INVALID_RATE_LIMIT_OPTION);
18
- if (typeof options.keyLimit !== 'number') throw new Error(Errors.INVALID_KEY_LIMIT_OPTION);
19
- if (typeof options.syncWithHeaders !== 'boolean') throw new Error(Errors.INVALID_HEADER_SYNC_OPTION);
20
- if (typeof options.headers !== 'object') throw new Error(Errors.INVALID_HEADERS);
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 (typeof options !== 'object' || options === null) throw new Error(Errors.OPTIONS_MUST_BE_AN_OBJECT);
37
+ if ('object' !== typeof options || null === options) throw new Error(Errors.OPTIONS_MUST_BE_AN_OBJECT);
31
38
  return {
32
- cache: options.cache || false,
33
- cacheTime: options.cacheTime || 60,
34
- cacheSize: (options.cacheSize === -1 ? Infinity : options.cacheSize) || Infinity,
35
- cacheFilter: typeof options.cacheFilter === 'function' ? options.cacheFilter : this._handleFilter(options.cacheFilter),
36
- rateLimit: options.rateLimit || 'AUTO',
37
- keyLimit: options.keyLimit || 120,
38
- syncWithHeaders: !!options.syncWithHeaders,
39
- headers: options.headers || {},
40
- silent: !!options.silent,
41
- checkForUpdates: options.checkForUpdates || true
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 !== 'string') throw new Error(Errors.KEY_MUST_BE_A_STRING);
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 (typeof input !== 'object' || input === null) return false;
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 === 'object' && !Array.isArray(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 (nodeVersion < 12) throw new Error(Errors.NODE_VERSION_ERR);
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) || null;
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.TextContent.includes('Resolved -') || this.TextContent.includes('Completed -');
60
+ this.isResolved = this.HTMLContent.includes('Resolved -') || this.HTMLContent.includes('Completed -');
68
61
  }
69
62
  /**
70
- * Text Content
63
+ * HTML Content
71
64
  * @return {string}
72
65
  */
73
66
  toString() {
74
- return this.TextContent;
67
+ return this.HTMLContent;
75
68
  }
76
69
  }
77
70
 
@@ -31,7 +31,6 @@ class APIStatus {
31
31
  * All incidents that aren't completed/resolved
32
32
  * @author linearaccelerator
33
33
  * @type {APIIncident[]}
34
- * @version >6.0.1
35
34
  */
36
35
  this.currentIncidents = this.incidents.filter((i) => !i.isResolved);
37
36
  }
@@ -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 {String}
20
+ * @type {string}
13
21
  */
14
22
  this.purchaser = data.purchaserUuid;
15
23
  /**
16
24
  * Booster's multiplier
17
- * @type {Number}
25
+ * @type {number}
18
26
  */
19
27
  this.amount = data.amount;
20
28
  /**
21
29
  * Booster's length in seconds
22
- * @type {Number}
30
+ * @type {number}
23
31
  */
24
32
  this.originalLength = data.originalLength;
25
33
  /**
26
34
  * Length remaining in seconds
27
- * @type {Number}
35
+ * @type {number}
28
36
  */
29
37
  this.remaining = data.length;
30
38
  /**
31
39
  * Date activated timestamp
32
- * @type {Number}
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 < 0;
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;
@@ -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
- * * `BLACK`
75
- * * `DARK_BLUE`
76
- * * `DARK_GREEN`
77
- * * `DARK_AQUA`
78
- * * `DARK_RED`
79
- * * `DARK_PURPLE`
80
- * * `GOLD`
81
- * * `GRAY`
82
- * * `DARK_GRAY`
83
- * * `BLUE`
84
- * * `GREEN`
85
- * * `AQUA`
86
- * * `RED`
87
- * * `LIGHT_PURPLE`
88
- * * `YELLOW`
89
- * * `WHITE`
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: `Black`
94
- * * DARK_BLUE: `Dark Blue`
95
- * * DARK_GREEN: `Dark Green`
96
- * * DARK_AQUA: `Dark Aqua`
97
- * * DARK_RED: `Dark Red`
98
- * * DARK_PURPLE: `Dark Purple`
99
- * * GOLD: `Gold`
100
- * * GRAY: `Gray`
101
- * * DARK_GRAY: `Dark Gray`
102
- * * BLUE: `Blue`,
103
- * * GREEN: `Green`
104
- * * AQUA: `Aqua`
105
- * * RED: `Red`
106
- * * LIGHT_PURPLE: `Light Purple`
107
- * * YELLOW: `Yellow`
108
- * * WHITE: `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: `#000000`
113
- * * DARK_BLUE: `#0000AA`
114
- * * DARK_GREEN: `#008000`
115
- * * DARK_AQUA: `#00AAAA`
116
- * * DARK_RED: `#AA0000`
117
- * * DARK_PURPLE: `#AA00AA`
118
- * * GOLD: `#FFAA00`
119
- * * GRAY: `#AAAAAA`
120
- * * DARK_GRAY: `#555555`
121
- * * BLUE: `#5555FF`
122
- * * GREEN: `#3CE63C`
123
- * * AQUA: `#3CE6E6`
124
- * * RED: `#FF5555`
125
- * * LIGHT_PURPLE: `#FF55FF`
126
- * * YELLOW: `#FFFF55`
127
- * * WHITE: `#FFFFFF`
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;
@@ -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((g) => g.code.toLowerCase() === this.game || g.id.toString() === this.game || g.name.toLowerCase() === this.game);
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 = !!result;
37
+ this.found = Boolean(result);
36
38
  }
37
39
 
38
40
  /**