hypixel-api-reborn 10.0.0 → 11.0.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 (105) hide show
  1. package/.prettierrc +13 -0
  2. package/README.md +28 -16
  3. package/package.json +60 -58
  4. package/src/API/getAPIStatus.js +8 -8
  5. package/src/API/getBoosters.js +6 -6
  6. package/src/API/getGameCounts.js +6 -6
  7. package/src/API/getGuild.js +18 -18
  8. package/src/API/getLeaderboards.js +13 -13
  9. package/src/API/getPlayer.js +22 -27
  10. package/src/API/getRecentGames.js +18 -18
  11. package/src/API/getServerInfo.js +66 -77
  12. package/src/API/getStatus.js +8 -8
  13. package/src/API/getWatchdogStats.js +6 -6
  14. package/src/API/index.js +19 -23
  15. package/src/API/skyblock/getEndedSkyblockAuctions.js +10 -10
  16. package/src/API/skyblock/getSkyblockAuctions.js +64 -64
  17. package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +11 -11
  18. package/src/API/skyblock/getSkyblockBazaar.js +10 -10
  19. package/src/API/skyblock/getSkyblockMember.js +28 -25
  20. package/src/API/skyblock/getSkyblockNews.js +6 -6
  21. package/src/API/skyblock/getSkyblockProfiles.js +44 -41
  22. package/src/Client.js +406 -450
  23. package/src/Errors.js +44 -39
  24. package/src/Private/defaultCache.js +77 -78
  25. package/src/Private/rateLimit.js +79 -98
  26. package/src/Private/requests.js +65 -54
  27. package/src/Private/updater.js +45 -45
  28. package/src/Private/uuidCache.js +37 -33
  29. package/src/Private/validate.js +97 -97
  30. package/src/index.js +82 -83
  31. package/src/structures/APIIncident.js +78 -78
  32. package/src/structures/APIStatus.js +47 -47
  33. package/src/structures/Boosters/Booster.js +83 -87
  34. package/src/structures/Color.js +129 -129
  35. package/src/structures/Game.js +164 -160
  36. package/src/structures/GameCounts.js +151 -151
  37. package/src/structures/Guild/Guild.js +204 -218
  38. package/src/structures/Guild/GuildMember.js +66 -66
  39. package/src/structures/Guild/GuildRank.js +48 -48
  40. package/src/structures/ItemBytes.js +33 -36
  41. package/src/structures/Leaderboard.js +31 -31
  42. package/src/structures/MiniGames/Arcade.js +567 -569
  43. package/src/structures/MiniGames/ArenaBrawl.js +52 -56
  44. package/src/structures/MiniGames/BedWars.js +423 -351
  45. package/src/structures/MiniGames/BlitzSurvivalGames.js +172 -148
  46. package/src/structures/MiniGames/BuildBattle.js +53 -53
  47. package/src/structures/MiniGames/CopsAndCrims.js +90 -90
  48. package/src/structures/MiniGames/Duels.js +694 -630
  49. package/src/structures/MiniGames/MegaWalls.js +137 -137
  50. package/src/structures/MiniGames/MurderMystery.js +93 -93
  51. package/src/structures/MiniGames/Paintball.js +67 -67
  52. package/src/structures/MiniGames/Pit.js +19 -19
  53. package/src/structures/MiniGames/Quakecraft.js +101 -101
  54. package/src/structures/MiniGames/SkyWars.js +508 -559
  55. package/src/structures/MiniGames/SmashHeroes.js +144 -151
  56. package/src/structures/MiniGames/SpeedUHC.js +115 -57
  57. package/src/structures/MiniGames/TNTGames.js +116 -116
  58. package/src/structures/MiniGames/TurboKartRacers.js +201 -176
  59. package/src/structures/MiniGames/UHC.js +164 -143
  60. package/src/structures/MiniGames/VampireZ.js +60 -60
  61. package/src/structures/MiniGames/Walls.js +52 -52
  62. package/src/structures/MiniGames/Warlords.js +62 -62
  63. package/src/structures/MiniGames/WoolWars.js +123 -0
  64. package/src/structures/Pet.js +96 -97
  65. package/src/structures/Pets.js +64 -64
  66. package/src/structures/Player.js +433 -449
  67. package/src/structures/PlayerCosmetics.js +100 -95
  68. package/src/structures/RecentGame.js +57 -57
  69. package/src/structures/ServerInfo.js +78 -78
  70. package/src/structures/SkyBlock/Auctions/Auction.js +104 -104
  71. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +54 -54
  72. package/src/structures/SkyBlock/Auctions/BaseAuction.js +45 -45
  73. package/src/structures/SkyBlock/Auctions/Bid.js +48 -48
  74. package/src/structures/SkyBlock/Auctions/PartialAuction.js +25 -25
  75. package/src/structures/SkyBlock/Bazzar/Order.js +38 -38
  76. package/src/structures/SkyBlock/Bazzar/Product.js +53 -53
  77. package/src/structures/SkyBlock/News/SkyblockNews.js +60 -68
  78. package/src/structures/SkyBlock/SkyblockInventoryItem.js +124 -130
  79. package/src/structures/SkyBlock/SkyblockMember.js +820 -687
  80. package/src/structures/SkyBlock/SkyblockPet.js +71 -71
  81. package/src/structures/SkyBlock/SkyblockProfile.js +60 -60
  82. package/src/structures/Status.js +41 -41
  83. package/src/structures/Watchdog/Stats.js +36 -36
  84. package/src/utils/Constants.js +2789 -809
  85. package/src/utils/SkyblockUtils.js +208 -164
  86. package/src/utils/arrayTools.js +4 -4
  87. package/src/utils/divide.js +5 -5
  88. package/src/utils/guildExp.js +57 -67
  89. package/src/utils/index.js +13 -13
  90. package/src/utils/isGuildID.js +3 -3
  91. package/src/utils/isUUID.js +5 -5
  92. package/src/utils/oscillation.js +15 -23
  93. package/src/utils/removeSnakeCase.js +22 -35
  94. package/src/utils/rgbToHexColor.js +8 -8
  95. package/src/utils/romanize.js +11 -13
  96. package/src/utils/toIGN.js +20 -20
  97. package/src/utils/toUuid.js +19 -19
  98. package/src/utils/varInt.js +17 -21
  99. package/typings/index.d.ts +3532 -2644
  100. package/src/API/getFriends.js +0 -14
  101. package/src/API/getKeyInfo.js +0 -10
  102. package/src/API/getRankedSkyWars.js +0 -11
  103. package/src/structures/Friend.js +0 -38
  104. package/src/structures/KeyInfo.js +0 -42
  105. package/src/structures/MiniGames/SkyWarsRanked.js +0 -45
@@ -1,54 +1,54 @@
1
- /* eslint-disable require-jsdoc */
2
- /**
3
- * Auction info class
4
- */
5
- class AuctionInfo {
6
- /**
7
- * @param {object} data Auction info data
8
- */
9
- constructor (data) {
10
- /**
11
- * Page number
12
- * @type {number}
13
- */
14
- this.page = parseInt(data.page, 10) || 0;
15
- /**
16
- * Total pages
17
- * @type {number}
18
- */
19
- this.totalPages = parseInt(data.totalPages, 10) || 1;
20
- /**
21
- * Total auctions
22
- * @type {number}
23
- */
24
- this.totalAuctions = parseInt(data.totalAuctions, 10) || 0;
25
- /**
26
- * Last updated timestamp
27
- * @type {number}
28
- */
29
- this.lastUpdatedTimestamp = data.lastUpdated;
30
- /**
31
- * Last updated timestamp as Date
32
- * @type {Date}
33
- */
34
- this.lastUpdatedAt = new Date(data.lastUpdated);
35
- /**
36
- * Age
37
- * @type {number}
38
- */
39
- this.age = parseInt(data._headers.get('age'), 10) || 0;
40
- }
41
-
42
- _extend (name, value) {
43
- this[name] = value;
44
- return this;
45
- }
46
- /**
47
- * Current Page / Total Page
48
- * @return {string}
49
- */
50
- toString() {
51
- return `${this.page} / ${this.totalPages}`;
52
- }
53
- }
54
- module.exports = AuctionInfo;
1
+ /* eslint-disable require-jsdoc */
2
+ /**
3
+ * Auction info class
4
+ */
5
+ class AuctionInfo {
6
+ /**
7
+ * @param {object} data Auction info data
8
+ */
9
+ constructor(data) {
10
+ /**
11
+ * Page number
12
+ * @type {number}
13
+ */
14
+ this.page = parseInt(data.page, 10) || 0;
15
+ /**
16
+ * Total pages
17
+ * @type {number}
18
+ */
19
+ this.totalPages = parseInt(data.totalPages, 10) || 1;
20
+ /**
21
+ * Total auctions
22
+ * @type {number}
23
+ */
24
+ this.totalAuctions = parseInt(data.totalAuctions, 10) || 0;
25
+ /**
26
+ * Last updated timestamp
27
+ * @type {number}
28
+ */
29
+ this.lastUpdatedTimestamp = data.lastUpdated;
30
+ /**
31
+ * Last updated timestamp as Date
32
+ * @type {Date}
33
+ */
34
+ this.lastUpdatedAt = new Date(data.lastUpdated);
35
+ /**
36
+ * Age
37
+ * @type {number}
38
+ */
39
+ this.age = parseInt(data._headers.get('age'), 10) || 0;
40
+ }
41
+
42
+ _extend(name, value) {
43
+ this[name] = value;
44
+ return this;
45
+ }
46
+ /**
47
+ * Current Page / Total Page
48
+ * @return {string}
49
+ */
50
+ toString() {
51
+ return `${this.page} / ${this.totalPages}`;
52
+ }
53
+ }
54
+ module.exports = AuctionInfo;
@@ -1,45 +1,45 @@
1
- const ItemBytes = require('../../ItemBytes');
2
- /**
3
- * Base auction class
4
- */
5
- class BaseAuction {
6
- /**
7
- * @param {object} data Base auction data
8
- * @param {boolean} includeItemBytes
9
- */
10
- constructor (data, includeItemBytes) {
11
- /**
12
- * Auction ID
13
- * @type {string|null}
14
- */
15
- this.auctionId = data.uuid || data.auction_id || null;
16
- /**
17
- * Auctioneer UUID
18
- * @type {string|null}
19
- */
20
- this.auctioneerUuid = data.auctioneer || data.seller || null;
21
- /**
22
- * Auctioneer's skyblock profile ID
23
- * @type {string|null}
24
- */
25
- this.auctioneerProfile = data.profile_id || data.seller_profile || null;
26
- /**
27
- * Bin
28
- * @type {boolean}
29
- */
30
- this.bin = data.bin || false;
31
- /**
32
- * Item bytes
33
- * @type {ItemBytes|null}
34
- */
35
- this.itemBytes = includeItemBytes ? (new ItemBytes(data.item_bytes) || null) : null;
36
- }
37
- /**
38
- * Auction ID
39
- * @return {string}
40
- */
41
- toString() {
42
- return this.auctionId;
43
- }
44
- }
45
- module.exports = BaseAuction;
1
+ const ItemBytes = require('../../ItemBytes');
2
+ /**
3
+ * Base auction class
4
+ */
5
+ class BaseAuction {
6
+ /**
7
+ * @param {object} data Base auction data
8
+ * @param {boolean} includeItemBytes
9
+ */
10
+ constructor(data, includeItemBytes) {
11
+ /**
12
+ * Auction ID
13
+ * @type {string|null}
14
+ */
15
+ this.auctionId = data.uuid || data.auction_id || null;
16
+ /**
17
+ * Auctioneer UUID
18
+ * @type {string|null}
19
+ */
20
+ this.auctioneerUuid = data.auctioneer || data.seller || null;
21
+ /**
22
+ * Auctioneer's skyblock profile ID
23
+ * @type {string|null}
24
+ */
25
+ this.auctioneerProfile = data.profile_id || data.seller_profile || null;
26
+ /**
27
+ * Bin
28
+ * @type {boolean}
29
+ */
30
+ this.bin = data.bin || false;
31
+ /**
32
+ * Item bytes
33
+ * @type {ItemBytes|null}
34
+ */
35
+ this.itemBytes = includeItemBytes ? new ItemBytes(data.item_bytes) || null : null;
36
+ }
37
+ /**
38
+ * Auction ID
39
+ * @return {string}
40
+ */
41
+ toString() {
42
+ return this.auctionId;
43
+ }
44
+ }
45
+ module.exports = BaseAuction;
@@ -1,48 +1,48 @@
1
- /**
2
- * Bid class
3
- */
4
- class Bid {
5
- /**
6
- * @param {object} data Bid data
7
- */
8
- constructor (data) {
9
- /**
10
- * Auction ID
11
- * @type {string|null}
12
- */
13
- this.auctionId = data.auction_id || null;
14
- /**
15
- * Skyblock profile ID
16
- * @type {string|null}
17
- */
18
- this.profileId = data.profile_id || null;
19
- /**
20
- * Amount
21
- * @type {number}
22
- */
23
- this.amount = data.amount || 0;
24
- /**
25
- * Auction timestamp
26
- * @type {number}
27
- */
28
- this.timestamp = data.timestamp || null;
29
- /**
30
- * Auction timestamp as Date
31
- * @type {Date}
32
- */
33
- this.at = data.timestamp ? new Date(data.timestamp) : null;
34
- /**
35
- * Bidder
36
- * @type {string}
37
- */
38
- this.bidder = data.bidder || null;
39
- }
40
- /**
41
- * Bidder Name - Bid Amount
42
- * @return {string}
43
- */
44
- toString() {
45
- return `${this.bidder} bid ${this.amount} coins`;
46
- }
47
- }
48
- module.exports = Bid;
1
+ /**
2
+ * Bid class
3
+ */
4
+ class Bid {
5
+ /**
6
+ * @param {object} data Bid data
7
+ */
8
+ constructor(data) {
9
+ /**
10
+ * Auction ID
11
+ * @type {string|null}
12
+ */
13
+ this.auctionId = data.auction_id || null;
14
+ /**
15
+ * Skyblock profile ID
16
+ * @type {string|null}
17
+ */
18
+ this.profileId = data.profile_id || null;
19
+ /**
20
+ * Amount
21
+ * @type {number}
22
+ */
23
+ this.amount = data.amount || 0;
24
+ /**
25
+ * Auction timestamp
26
+ * @type {number}
27
+ */
28
+ this.timestamp = data.timestamp || null;
29
+ /**
30
+ * Auction timestamp as Date
31
+ * @type {Date}
32
+ */
33
+ this.at = data.timestamp ? new Date(data.timestamp) : null;
34
+ /**
35
+ * Bidder
36
+ * @type {string}
37
+ */
38
+ this.bidder = data.bidder || null;
39
+ }
40
+ /**
41
+ * Bidder Name - Bid Amount
42
+ * @return {string}
43
+ */
44
+ toString() {
45
+ return `${this.bidder} bid ${this.amount} coins`;
46
+ }
47
+ }
48
+ module.exports = Bid;
@@ -1,25 +1,25 @@
1
- const BaseAuction = require('./BaseAuction');
2
- /**
3
- * Partial auction class
4
- * @extends {BaseAuction}
5
- */
6
- class PartialAuction extends BaseAuction {
7
- /**
8
- * @param {object} data Partial auction data
9
- * @param {boolean} includeItemBytes
10
- */
11
- constructor (data, includeItemBytes) {
12
- super(data, includeItemBytes);
13
- /**
14
- * Buyer UUID
15
- * @type {string}
16
- */
17
- this.buyer = data.buyer || null;
18
- /**
19
- * Price
20
- * @type {number}
21
- */
22
- this.price = parseInt(data.price, 10) || 0;
23
- }
24
- }
25
- module.exports = PartialAuction;
1
+ const BaseAuction = require('./BaseAuction');
2
+ /**
3
+ * Partial auction class
4
+ * @extends {BaseAuction}
5
+ */
6
+ class PartialAuction extends BaseAuction {
7
+ /**
8
+ * @param {object} data Partial auction data
9
+ * @param {boolean} includeItemBytes
10
+ */
11
+ constructor(data, includeItemBytes) {
12
+ super(data, includeItemBytes);
13
+ /**
14
+ * Buyer UUID
15
+ * @type {string}
16
+ */
17
+ this.buyer = data.buyer || null;
18
+ /**
19
+ * Price
20
+ * @type {number}
21
+ */
22
+ this.price = parseInt(data.price, 10) || 0;
23
+ }
24
+ }
25
+ module.exports = PartialAuction;
@@ -1,38 +1,38 @@
1
- /**
2
- * Order class
3
- */
4
- class Order {
5
- /**
6
- * @param {object} data Order data
7
- */
8
- constructor (data) {
9
- /**
10
- * Amount
11
- * @type {number}
12
- */
13
- this.amount = data.amount || 0;
14
- /**
15
- * Price per unit
16
- * @type {number}
17
- */
18
- this.pricePerUnit = data.pricePerUnit || 0;
19
- /**
20
- * Total price
21
- * @type {number}
22
- */
23
- this.totalPrice = Math.round((this.amount * this.pricePerUnit) * 10) / 10;
24
- /**
25
- * Orders
26
- * @type {number}
27
- */
28
- this.orders = data.orders || 0;
29
- }
30
- /**
31
- * Price as string
32
- * @return {string}
33
- */
34
- toString() {
35
- return this.totalPrice;
36
- }
37
- }
38
- module.exports = Order;
1
+ /**
2
+ * Order class
3
+ */
4
+ class Order {
5
+ /**
6
+ * @param {object} data Order data
7
+ */
8
+ constructor(data) {
9
+ /**
10
+ * Amount
11
+ * @type {number}
12
+ */
13
+ this.amount = data.amount || 0;
14
+ /**
15
+ * Price per unit
16
+ * @type {number}
17
+ */
18
+ this.pricePerUnit = data.pricePerUnit || 0;
19
+ /**
20
+ * Total price
21
+ * @type {number}
22
+ */
23
+ this.totalPrice = Math.round(this.amount * this.pricePerUnit * 10) / 10;
24
+ /**
25
+ * Orders
26
+ * @type {number}
27
+ */
28
+ this.orders = data.orders || 0;
29
+ }
30
+ /**
31
+ * Price as string
32
+ * @return {string}
33
+ */
34
+ toString() {
35
+ return this.totalPrice;
36
+ }
37
+ }
38
+ module.exports = Order;
@@ -1,53 +1,53 @@
1
- const Order = require('./Order');
2
-
3
- /**
4
- * Product class
5
- */
6
- class Product {
7
- /**
8
- * @param {object} data Product data
9
- */
10
- constructor (data) {
11
- /**
12
- * Product ID
13
- * @type {string}
14
- */
15
- this.productId = data.product_id;
16
- /**
17
- * Product sell orders
18
- * @type {Order[]}
19
- */
20
- this.sellSummary = data.sell_summary.length ? data.sell_summary.map((sellOrder) => new Order(sellOrder)) : [];
21
- /**
22
- * Product buy orders
23
- * @type {Order[]}
24
- */
25
- this.buySummary = data.buy_summary.length ? data.buy_summary.map((buyOrder) => new Order(buyOrder)) : [];
26
- /**
27
- * Product status
28
- * @type {ProductStatus}
29
- */
30
- this.status = {
31
- sellPrice: isNaN(data.quick_status.sellPrice) ? 0 : Math.round(data.quick_status.sellPrice * 100) / 100,
32
- buyPrice: isNaN(data.quick_status.buyPrice) ? 0 : Math.round(data.quick_status.buyPrice * 100) / 100,
33
- sellVolume: isNaN(data.quick_status.sellVolume) ? 0 : data.quick_status.sellVolume,
34
- buyVolume: isNaN(data.quick_status.buyVolume) ? 0 : data.quick_status.buyVolume,
35
- sellMovingWeek: isNaN(data.quick_status.sellMovingWeek) ? 0 : data.quick_status.sellMovingWeek,
36
- buyMovingWeek: isNaN(data.quick_status.buyMovingWeek) ? 0 : data.quick_status.buyMovingWeek,
37
- sellOrders: isNaN(data.quick_status.sellOrders) ? 0 : data.quick_status.sellOrders,
38
- buyOrders: isNaN(data.quick_status.buyOrders) ? 0 : data.quick_status.buyOrders
39
- };
40
- }
41
- }
42
- /**
43
- * @typedef {object} ProductStatus
44
- * @property {number} sellPrice Sell price
45
- * @property {number} buyPrice Buy price
46
- * @property {number} sellVolume Sell volume
47
- * @property {number} buyVolume Buy volume
48
- * @property {number} sellMovingWeek Sell moving week
49
- * @property {number} buyMovingWeek Sell moving week
50
- * @property {number} sellOrders Sell orders
51
- * @property {number} buyOrders Buy orders
52
- */
53
- module.exports = Product;
1
+ const Order = require('./Order');
2
+
3
+ /**
4
+ * Product class
5
+ */
6
+ class Product {
7
+ /**
8
+ * @param {object} data Product data
9
+ */
10
+ constructor(data) {
11
+ /**
12
+ * Product ID
13
+ * @type {string}
14
+ */
15
+ this.productId = data.product_id;
16
+ /**
17
+ * Product sell orders
18
+ * @type {Order[]}
19
+ */
20
+ this.sellSummary = data.sell_summary.length ? data.sell_summary.map((sellOrder) => new Order(sellOrder)) : [];
21
+ /**
22
+ * Product buy orders
23
+ * @type {Order[]}
24
+ */
25
+ this.buySummary = data.buy_summary.length ? data.buy_summary.map((buyOrder) => new Order(buyOrder)) : [];
26
+ /**
27
+ * Product status
28
+ * @type {ProductStatus}
29
+ */
30
+ this.status = {
31
+ sellPrice: isNaN(data.quick_status.sellPrice) ? 0 : Math.round(data.quick_status.sellPrice * 100) / 100,
32
+ buyPrice: isNaN(data.quick_status.buyPrice) ? 0 : Math.round(data.quick_status.buyPrice * 100) / 100,
33
+ sellVolume: isNaN(data.quick_status.sellVolume) ? 0 : data.quick_status.sellVolume,
34
+ buyVolume: isNaN(data.quick_status.buyVolume) ? 0 : data.quick_status.buyVolume,
35
+ sellMovingWeek: isNaN(data.quick_status.sellMovingWeek) ? 0 : data.quick_status.sellMovingWeek,
36
+ buyMovingWeek: isNaN(data.quick_status.buyMovingWeek) ? 0 : data.quick_status.buyMovingWeek,
37
+ sellOrders: isNaN(data.quick_status.sellOrders) ? 0 : data.quick_status.sellOrders,
38
+ buyOrders: isNaN(data.quick_status.buyOrders) ? 0 : data.quick_status.buyOrders
39
+ };
40
+ }
41
+ }
42
+ /**
43
+ * @typedef {object} ProductStatus
44
+ * @property {number} sellPrice Sell price
45
+ * @property {number} buyPrice Buy price
46
+ * @property {number} sellVolume Sell volume
47
+ * @property {number} buyVolume Buy volume
48
+ * @property {number} sellMovingWeek Sell moving week
49
+ * @property {number} buyMovingWeek Sell moving week
50
+ * @property {number} sellOrders Sell orders
51
+ * @property {number} buyOrders Buy orders
52
+ */
53
+ module.exports = Product;
@@ -1,68 +1,60 @@
1
- const dateRegExp = /(\d{1,2})(?:st|nd|rd|th|) ([A-z]+) (\d+)/;
2
- const versionRegExp = /v\d+(\.\d+){1,}/;
3
- /**
4
- * SkyblockNews
5
- */
6
- class SkyblockNews {
7
- /**
8
- * @param {object} data
9
- */
10
- constructor (data) {
11
- /**
12
- * Title
13
- * @type {string}
14
- */
15
- this.title = data.title;
16
- /**
17
- * Thread
18
- * @type {string}
19
- */
20
- this.link = data.link;
21
- /**
22
- * Raw Date from the API Response
23
- * @type {string}
24
- */
25
- this.rawDate = data.text;
26
- /**
27
- * Parsed Date
28
- * @type {Date}
29
- */
30
- this.date = parseDate(data.text);
31
- /**
32
- * The version from the title (Skyblock v0.12.57673856757.327.2 => v0.12.57673856757.327.2)
33
- * @author linearaccelerator
34
- * @type {string | null}
35
- * @version >6.0.1
36
- */
37
- this.version = parseVer(this.title);
38
- }
39
- /**
40
- * News title
41
- * @return {string}
42
- */
43
- toString() {
44
- return this.title;
45
- }
46
- }
47
- /**
48
- * Parses a string date
49
- * @param {string} stringDate
50
- * @returns {Date | null}
51
- */
52
- function parseDate(stringDate) {
53
- const matched = stringDate.match(dateRegExp);
54
- if (!matched) return null;
55
- return new Date(matched.slice(1).join(' ')); // Ok this is lazy, but should work
56
- }
57
-
58
- /**
59
- * Parses the version from a string
60
- * @param {string} stringVer
61
- * @returns {string | null}
62
- */
63
- function parseVer(stringVer) {
64
- const matches = versionRegExp.exec(stringVer);
65
- if (!matches.length) return null; // this shouldn't really happen
66
- return matches[0];
67
- }
68
- module.exports = SkyblockNews;
1
+ const dateRegExp = /(\d{1,2})(?:st|nd|rd|th|) ([A-z]+) (\d+)/;
2
+ const versionRegExp = /v\d+(\.\d+){1,}/;
3
+ /**
4
+ * SkyblockNews
5
+ */
6
+ class SkyblockNews {
7
+ /**
8
+ * @param {object} data
9
+ */
10
+ constructor(data) {
11
+ /**
12
+ * Title
13
+ * @type {string}
14
+ */
15
+ this.title = data.title;
16
+ /**
17
+ * Thread
18
+ * @type {string}
19
+ */
20
+ this.link = data.link;
21
+ /**
22
+ * Raw Date from the API Response
23
+ * @type {string}
24
+ */
25
+ this.rawDate = data.text;
26
+ /**
27
+ * Parsed Date
28
+ * @type {Date}
29
+ */
30
+ this.date = parseDate(data.text);
31
+ /**
32
+ * The version from the title (Skyblock v0.12.57673856757.327.2 => v0.12.57673856757.327.2)
33
+ * @author linearaccelerator
34
+ * @type {string | null}
35
+ * @version >6.0.1
36
+ */
37
+ this.version = parseVer(this.title);
38
+ }
39
+ /**
40
+ * News title
41
+ * @return {string}
42
+ */
43
+ toString() {
44
+ return this.title;
45
+ }
46
+ }
47
+ // eslint-disable-next-line require-jsdoc
48
+ function parseDate(stringDate) {
49
+ const matched = stringDate.match(dateRegExp);
50
+ if (!matched) return null;
51
+ return new Date(matched.slice(1).join(' ')); // Ok this is lazy, but should work
52
+ }
53
+
54
+ // eslint-disable-next-line require-jsdoc
55
+ function parseVer(stringVer) {
56
+ const matches = versionRegExp.exec(stringVer);
57
+ if (!matches?.length) return null; // this shouldn't really happen
58
+ return matches[0];
59
+ }
60
+ module.exports = SkyblockNews;