hypixel-api-reborn 9.0.3 → 11.0.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.
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 -7
  5. package/src/API/getBoosters.js +6 -5
  6. package/src/API/getGameCounts.js +6 -5
  7. package/src/API/getGuild.js +18 -17
  8. package/src/API/getLeaderboards.js +13 -12
  9. package/src/API/getPlayer.js +22 -26
  10. package/src/API/getRecentGames.js +18 -17
  11. package/src/API/getServerInfo.js +66 -77
  12. package/src/API/getStatus.js +8 -7
  13. package/src/API/getWatchdogStats.js +6 -5
  14. package/src/API/index.js +19 -9
  15. package/src/API/skyblock/getEndedSkyblockAuctions.js +10 -9
  16. package/src/API/skyblock/getSkyblockAuctions.js +64 -64
  17. package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +11 -10
  18. package/src/API/skyblock/getSkyblockBazaar.js +10 -9
  19. package/src/API/skyblock/getSkyblockMember.js +28 -24
  20. package/src/API/skyblock/getSkyblockNews.js +6 -5
  21. package/src/API/skyblock/getSkyblockProfiles.js +44 -40
  22. package/src/Client.js +406 -430
  23. package/src/Errors.js +44 -38
  24. package/src/Private/defaultCache.js +77 -0
  25. package/src/Private/rateLimit.js +79 -98
  26. package/src/Private/requests.js +65 -39
  27. package/src/Private/updater.js +45 -42
  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 -329
  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 -460
  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 -71
  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 -453
  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 -102
  79. package/src/structures/SkyBlock/SkyblockMember.js +820 -675
  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 -795
  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 -9
  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 -0
  95. package/src/utils/romanize.js +11 -0
  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 -2625
  100. package/src/API/getFriends.js +0 -13
  101. package/src/API/getKeyInfo.js +0 -9
  102. package/src/API/getRankedSkyWars.js +0 -10
  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,95 +1,100 @@
1
- const Pets = require('./Pets');
2
- const { removeSnakeCaseString } = require('../utils/removeSnakeCase');
3
- /**
4
- * Player Cosmetics class
5
- */
6
- class PlayerCosmetics {
7
- /**
8
- * @param {object} data data
9
- */
10
- constructor (data) {
11
- /**
12
- * All cosmetics
13
- * @type {string[]}
14
- */
15
- this.allCosmetics = data.vanityMeta ? data.vanityMeta.packages : undefined;
16
- /**
17
- * Pets
18
- * @type {Pets|null}
19
- */
20
- this.petManager = this.allCosmetics ? new Pets(this.allCosmetics.filter((x) => x.startsWith('pet_')), data) : null;
21
- }
22
- /**
23
- * Suits
24
- * @type {string[]}
25
- */
26
- get suits () {
27
- if (!this._suits) this._suits = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('suit_')).map((x) => removeSnakeCaseString(x.replace('suit_', ''))) || [] : [];
28
- return this._suits;
29
- }
30
- /**
31
- * Hats
32
- * @type {string[]}
33
- */
34
- get hats () {
35
- if (!this._hats) this._hats = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('hat_')).map((x) => removeSnakeCaseString(x.replace('hat_', ''))) || [] : [];
36
- return this._hats;
37
- }
38
- /**
39
- * Gadgets
40
- * @type {string[]}
41
- */
42
- get gadgets () {
43
- if (!this._gadgets) this._gadgets = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('gadget_')).map((x) => removeSnakeCaseString(x.replace('gadget_', ''))) || [] : [];
44
- return this._gadgets;
45
- }
46
- /**
47
- * Morphs
48
- * @type {string[]}
49
- */
50
- get morphs () {
51
- if (!this._morphs) this._morphs = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('morph_')).map((x) => removeSnakeCaseString(x.replace('morph_', ''))) || [] : [];
52
- return this._morphs;
53
- }
54
- /**
55
- * Cloaks
56
- * @type {string[]}
57
- */
58
- get cloaks () {
59
- if (!this._cloaks) this._cloaks = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('cloak_')).map((x) => removeSnakeCaseString(x.replace('cloak_', ''))) || [] : [];
60
- return this._cloaks;
61
- }
62
- /**
63
- * Taunts
64
- * @type {string[]}
65
- */
66
- get taunts () {
67
- if (!this._taunts) this._taunts = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('taunt_')).map((x) => removeSnakeCaseString(x.replace('taunt_', ''))) || [] : [];
68
- return this._taunts;
69
- }
70
- /**
71
- * rankColors
72
- * @type {string[]}
73
- */
74
- get rankColors () {
75
- if (!this._rankcolors) this._rankcolors = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('rankcolor_')).map((x) => removeSnakeCaseString(x.replace('rankcolor_', ''))) || [] : [];
76
- return this._rankcolors;
77
- }
78
- /**
79
- * Particle Packs
80
- * @type {string[]}
81
- */
82
- get particlePacks () {
83
- if (!this._particle) this._particle = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('particlepack_')).map((x) => removeSnakeCaseString(x.replace('particlepack_', ''))) || [] : [];
84
- return this._particlepacks;
85
- }
86
- /**
87
- * Click Effects
88
- * @type {string[]}
89
- */
90
- get clickEffects () {
91
- if (!this._clickfx) this._clickfx = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('clickeffects_')).map((x) => removeSnakeCaseString(x.replace('clickeffects_', ''))) || [] : [];
92
- return this._clickfx;
93
- }
94
- }
95
- module.exports = PlayerCosmetics;
1
+ const Pets = require('./Pets');
2
+ const { removeSnakeCaseString } = require('../utils/removeSnakeCase');
3
+ /**
4
+ * Player Cosmetics class
5
+ */
6
+ class PlayerCosmetics {
7
+ /**
8
+ * @param {object} data data
9
+ */
10
+ constructor(data) {
11
+ /**
12
+ * All cosmetics
13
+ * @type {string[]}
14
+ */
15
+ this.allCosmetics = data.vanityMeta ? data.vanityMeta.packages : undefined;
16
+ /**
17
+ * Pets
18
+ * @type {Pets|null}
19
+ */
20
+ this.petManager = this.allCosmetics
21
+ ? new Pets(
22
+ this.allCosmetics.filter((x) => x.startsWith('pet_')),
23
+ data
24
+ )
25
+ : null;
26
+ }
27
+ /**
28
+ * Suits
29
+ * @type {string[]}
30
+ */
31
+ get suits() {
32
+ if (!this._suits) this._suits = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('suit_')).map((x) => removeSnakeCaseString(x.replace('suit_', ''))) || [] : [];
33
+ return this._suits;
34
+ }
35
+ /**
36
+ * Hats
37
+ * @type {string[]}
38
+ */
39
+ get hats() {
40
+ if (!this._hats) this._hats = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('hat_')).map((x) => removeSnakeCaseString(x.replace('hat_', ''))) || [] : [];
41
+ return this._hats;
42
+ }
43
+ /**
44
+ * Gadgets
45
+ * @type {string[]}
46
+ */
47
+ get gadgets() {
48
+ if (!this._gadgets) this._gadgets = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('gadget_')).map((x) => removeSnakeCaseString(x.replace('gadget_', ''))) || [] : [];
49
+ return this._gadgets;
50
+ }
51
+ /**
52
+ * Morphs
53
+ * @type {string[]}
54
+ */
55
+ get morphs() {
56
+ if (!this._morphs) this._morphs = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('morph_')).map((x) => removeSnakeCaseString(x.replace('morph_', ''))) || [] : [];
57
+ return this._morphs;
58
+ }
59
+ /**
60
+ * Cloaks
61
+ * @type {string[]}
62
+ */
63
+ get cloaks() {
64
+ if (!this._cloaks) this._cloaks = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('cloak_')).map((x) => removeSnakeCaseString(x.replace('cloak_', ''))) || [] : [];
65
+ return this._cloaks;
66
+ }
67
+ /**
68
+ * Taunts
69
+ * @type {string[]}
70
+ */
71
+ get taunts() {
72
+ if (!this._taunts) this._taunts = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('taunt_')).map((x) => removeSnakeCaseString(x.replace('taunt_', ''))) || [] : [];
73
+ return this._taunts;
74
+ }
75
+ /**
76
+ * rankColors
77
+ * @type {string[]}
78
+ */
79
+ get rankColors() {
80
+ if (!this._rankcolors) this._rankcolors = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('rankcolor_')).map((x) => removeSnakeCaseString(x.replace('rankcolor_', ''))) || [] : [];
81
+ return this._rankcolors;
82
+ }
83
+ /**
84
+ * Particle Packs
85
+ * @type {string[]}
86
+ */
87
+ get particlePacks() {
88
+ if (!this._particle) this._particle = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('particlepack_')).map((x) => removeSnakeCaseString(x.replace('particlepack_', ''))) || [] : [];
89
+ return this._particlepacks;
90
+ }
91
+ /**
92
+ * Click Effects
93
+ * @type {string[]}
94
+ */
95
+ get clickEffects() {
96
+ if (!this._clickfx) this._clickfx = this.allCosmetics ? this.allCosmetics.filter((x) => x.startsWith('clickeffects_')).map((x) => removeSnakeCaseString(x.replace('clickeffects_', ''))) || [] : [];
97
+ return this._clickfx;
98
+ }
99
+ }
100
+ module.exports = PlayerCosmetics;
@@ -1,57 +1,57 @@
1
- const Game = require('./Game');
2
- /**
3
- * RecentGame class
4
- * @extends {Game}
5
- */
6
- class RecentGame extends Game {
7
- /**
8
- * @param {object} data Recent game data
9
- */
10
- constructor (data) {
11
- super(data.gameType);
12
- /**
13
- * Date as timestamp
14
- * @type {number}
15
- */
16
- this.dateTimestamp = data.date || null;
17
- /**
18
- * Date
19
- * @type {Date}
20
- */
21
- this.date = data.date ? new Date(data.date) : null;
22
- /**
23
- * Game mode
24
- * @type {string}
25
- */
26
- this.mode = data.mode || null;
27
- /**
28
- * Map
29
- * @type {string}
30
- */
31
- this.map = data.map || null;
32
- // Per hypixel API docs : if ended isn't present, the game is ONGOING.
33
- /**
34
- * Is game ongoing?
35
- * @type {boolean}
36
- */
37
- this.ongoing = Boolean(!data.ended);
38
- /**
39
- * Game ended at as Date
40
- * @type {Date}
41
- */
42
- this.endedAt = data.ended ? new Date(data.ended) : null;
43
- /**
44
- * Game ended at
45
- * @type {number}
46
- */
47
- this.endedTimestamp = data.ended ? data.ended : null;
48
- }
49
- /**
50
- * Name of gamemode
51
- * @return {string}
52
- */
53
- toString() {
54
- return this.mode;
55
- }
56
- }
57
- module.exports = RecentGame;
1
+ const Game = require('./Game');
2
+ /**
3
+ * RecentGame class
4
+ * @extends {Game}
5
+ */
6
+ class RecentGame extends Game {
7
+ /**
8
+ * @param {object} data Recent game data
9
+ */
10
+ constructor(data) {
11
+ super(data.gameType);
12
+ /**
13
+ * Date as timestamp
14
+ * @type {number}
15
+ */
16
+ this.dateTimestamp = data.date || null;
17
+ /**
18
+ * Date
19
+ * @type {Date}
20
+ */
21
+ this.date = data.date ? new Date(data.date) : null;
22
+ /**
23
+ * Game mode
24
+ * @type {string}
25
+ */
26
+ this.mode = data.mode || null;
27
+ /**
28
+ * Map
29
+ * @type {string}
30
+ */
31
+ this.map = data.map || null;
32
+ // Per hypixel API docs : if ended isn't present, the game is ONGOING.
33
+ /**
34
+ * Is game ongoing?
35
+ * @type {boolean}
36
+ */
37
+ this.ongoing = Boolean(!data.ended);
38
+ /**
39
+ * Game ended at as Date
40
+ * @type {Date}
41
+ */
42
+ this.endedAt = data.ended ? new Date(data.ended) : null;
43
+ /**
44
+ * Game ended at
45
+ * @type {number}
46
+ */
47
+ this.endedTimestamp = data.ended ? data.ended : null;
48
+ }
49
+ /**
50
+ * Name of gamemode
51
+ * @return {string}
52
+ */
53
+ toString() {
54
+ return this.mode;
55
+ }
56
+ }
57
+ module.exports = RecentGame;
@@ -1,78 +1,78 @@
1
- /**
2
- * Server Info class - parses info obtained from handshaking with hypixel
3
- */
4
- class ServerInfo {
5
- /**
6
- * Constructor
7
- * @param {Object} data data parsed from packet
8
- * @param {number} ping Ping
9
- */
10
- constructor (data, ping) {
11
- /**
12
- * Protocol used for retrieving info, should be 736
13
- * @type {Number}
14
- */
15
- this.protocolUsed = data.version.protocol || 736;
16
- /**
17
- * Version required / Server version used
18
- * @type {string}
19
- */
20
- this.versionInfo = data.version.name || 'Unknown';
21
- /**
22
- * Amount of players online and max players
23
- * @type {PlayerInfo}
24
- */
25
- this.players = {
26
- max: data.players.max || 0,
27
- online: data.players.online || 0,
28
- players: data.players.sample || [],
29
- toString: () => `${this.players.online}/${this.players.max}`
30
- };
31
- /**
32
- * Server MOTD, as it is received
33
- * @type {string}
34
- */
35
- this.rawMOTD = data.description || '';
36
- /**
37
- * Clean MOTD, no color codes
38
- * @type {string}
39
- */
40
- this.cleanMOTD = this.rawMOTD.replace(/§[a-z0-9]/gi, '');
41
- /**
42
- * MOTD without surrounding white spaces for centering
43
- * @type {string}
44
- */
45
- this.textMOTD = this.cleanMOTD.replace(/^\s+/gm, '');
46
- /**
47
- * base64 Favicon - as it is received
48
- * @type {string}
49
- */
50
- this.faviconB64 = data.favicon || undefined;
51
- /**
52
- * Favicon as buffer
53
- * @type {Buffer}
54
- */
55
- this.favicon = Buffer.from(this.faviconB64, 'base64');
56
- /**
57
- * Ping in ms
58
- * @type {number}
59
- */
60
- this.ping = parseInt(ping);
61
- }
62
- /**
63
- * toString override
64
- * @returns {string}
65
- */
66
- toString () {
67
- return `${this.textMOTD} - ${this.players} Players (${this.ping} ms) - ${this.versionInfo}`;
68
- }
69
- }
70
-
71
- /**
72
- * @typedef {Object} PlayerInfo
73
- * @property {number} max Max amount of players online possible for the server
74
- * @property {number} online Current amount of online players
75
- * @property {any[]} players Some or all IGNs of online players, usually not provided by Hypixel
76
- */
77
-
78
- module.exports = ServerInfo;
1
+ /**
2
+ * Server Info class - parses info obtained from handshaking with hypixel
3
+ */
4
+ class ServerInfo {
5
+ /**
6
+ * Constructor
7
+ * @param {Object} data data parsed from packet
8
+ * @param {number} ping Ping
9
+ */
10
+ constructor(data, ping) {
11
+ /**
12
+ * Protocol used for retrieving info, should be 736
13
+ * @type {Number}
14
+ */
15
+ this.protocolUsed = data.version.protocol || 736;
16
+ /**
17
+ * Version required / Server version used
18
+ * @type {string}
19
+ */
20
+ this.versionInfo = data.version.name || 'Unknown';
21
+ /**
22
+ * Amount of players online and max players
23
+ * @type {PlayerInfo}
24
+ */
25
+ this.players = {
26
+ max: data.players.max || 0,
27
+ online: data.players.online || 0,
28
+ players: data.players.sample || [],
29
+ toString: () => `${this.players.online}/${this.players.max}`
30
+ };
31
+ /**
32
+ * Server MOTD, as it is received
33
+ * @type {string}
34
+ */
35
+ this.rawMOTD = data.description || '';
36
+ /**
37
+ * Clean MOTD, no color codes
38
+ * @type {string}
39
+ */
40
+ this.cleanMOTD = this.rawMOTD.replace(/§[a-z0-9]/gi, '');
41
+ /**
42
+ * MOTD without surrounding white spaces for centering
43
+ * @type {string}
44
+ */
45
+ this.textMOTD = this.cleanMOTD.replace(/^\s+/gm, '');
46
+ /**
47
+ * base64 Favicon - as it is received
48
+ * @type {string}
49
+ */
50
+ this.faviconB64 = data.favicon || undefined;
51
+ /**
52
+ * Favicon as buffer
53
+ * @type {Buffer}
54
+ */
55
+ this.favicon = Buffer.from(this.faviconB64, 'base64');
56
+ /**
57
+ * Ping in ms
58
+ * @type {number}
59
+ */
60
+ this.ping = parseInt(ping, 10);
61
+ }
62
+ /**
63
+ * toString override
64
+ * @returns {string}
65
+ */
66
+ toString() {
67
+ return `${this.textMOTD} - ${this.players} Players (${this.ping} ms) - ${this.versionInfo}`;
68
+ }
69
+ }
70
+
71
+ /**
72
+ * @typedef {Object} PlayerInfo
73
+ * @property {number} max Max amount of players online possible for the server
74
+ * @property {number} online Current amount of online players
75
+ * @property {any[]} players Some or all IGNs of online players, usually not provided by Hypixel
76
+ */
77
+
78
+ module.exports = ServerInfo;
@@ -1,104 +1,104 @@
1
- const Bid = require('./Bid');
2
- const BaseAuction = require('./BaseAuction');
3
- /**
4
- * Auction class
5
- */
6
- class Auction extends BaseAuction {
7
- /**
8
- * @param {object} data
9
- * @param {boolean} includeItemBytes
10
- */
11
- constructor (data, includeItemBytes) {
12
- super(data, includeItemBytes);
13
- /**
14
- * Coop members. Array of UUIDs
15
- * @type {string[]}
16
- */
17
- this.coop = data.coop || [];
18
- /**
19
- * Auction start timestamp
20
- * @type {number|null}
21
- */
22
- this.auctionStartTimestamp = data.start || null;
23
- /**
24
- * Auction start timestamp as Date
25
- * @type {Date}
26
- */
27
- this.auctionStart = data.start ? new Date(data.start) : null;
28
- /**
29
- * Auction end timestamp as Date
30
- * @type {Date}
31
- */
32
- this.auctionEnd = data.end ? new Date(data.end) : null;
33
- /**
34
- * Auction end timestamp as timestamp
35
- * @type {number}
36
- */
37
- this.auctionEndTimestamp = data.end || null;
38
- /**
39
- * Auction Item Name
40
- * @type {string}
41
- */
42
- this.item = data.item_name || null;
43
- /**
44
- * Auction Item lore ( plain text )
45
- * @type {string}
46
- */
47
- this.itemLore = data.item_lore ? data.item_lore.replace(/§([1-9]|[a-l])|§/gm, '') : null;
48
- /**
49
- * Auctipn Item Lore as it is from the API
50
- * @type {string}
51
- */
52
- this.itemLoreRaw = data.item_lore || null;
53
- /**
54
- * Rarity of Item
55
- * @type {Rarity}
56
- */
57
- this.rarity = data.tier || null;
58
- /**
59
- * Auction starting bid, or price for BIN
60
- * @type {number}
61
- */
62
- this.startingBid = data.starting_bid || 0;
63
- /**
64
- * Auction's highest bid, if it is bidded or price for BIN
65
- * @type {number}
66
- */
67
- this.highestBid = (this.bin) ? data.starting_bid : data.highest_bid_amount || 0;
68
- /**
69
- * Auction bids
70
- * @type {Bid[]}
71
- */
72
- this.bids = data.bids.length ? data.bids.map((b) => new Bid(b)) : [];
73
- /**
74
- * is Auction Claimed
75
- * @type {boolean}
76
- */
77
- this.claimed = data.claimed || false;
78
- /**
79
- * Which bidders, if any, claimed
80
- * @type {string[]}
81
- */
82
- this.claimedBidders = this.claimed ? data.claimed_bidders : [];
83
- }
84
- /**
85
- * Item Name
86
- * @return {string}
87
- */
88
- toString() {
89
- return this.item;
90
- }
91
- }
92
- /**
93
- * @typedef {string} Rarity
94
- * * `VERY_SPECIAL`
95
- * * `SPECIAL`
96
- * * `SUPREME`
97
- * * `MYTHIC`
98
- * * `LEGENDARY`
99
- * * `EPIC`
100
- * * `RARE`
101
- * * `UNCOMMON`
102
- * * `COMMON`
103
- */
104
- module.exports = Auction;
1
+ const Bid = require('./Bid');
2
+ const BaseAuction = require('./BaseAuction');
3
+ /**
4
+ * Auction class
5
+ */
6
+ class Auction extends BaseAuction {
7
+ /**
8
+ * @param {object} data
9
+ * @param {boolean} includeItemBytes
10
+ */
11
+ constructor(data, includeItemBytes) {
12
+ super(data, includeItemBytes);
13
+ /**
14
+ * Coop members. Array of UUIDs
15
+ * @type {string[]}
16
+ */
17
+ this.coop = data.coop || [];
18
+ /**
19
+ * Auction start timestamp
20
+ * @type {number|null}
21
+ */
22
+ this.auctionStartTimestamp = data.start || null;
23
+ /**
24
+ * Auction start timestamp as Date
25
+ * @type {Date}
26
+ */
27
+ this.auctionStart = data.start ? new Date(data.start) : null;
28
+ /**
29
+ * Auction end timestamp as Date
30
+ * @type {Date}
31
+ */
32
+ this.auctionEnd = data.end ? new Date(data.end) : null;
33
+ /**
34
+ * Auction end timestamp as timestamp
35
+ * @type {number}
36
+ */
37
+ this.auctionEndTimestamp = data.end || null;
38
+ /**
39
+ * Auction Item Name
40
+ * @type {string}
41
+ */
42
+ this.item = data.item_name || null;
43
+ /**
44
+ * Auction Item lore ( plain text )
45
+ * @type {string}
46
+ */
47
+ this.itemLore = data.item_lore ? data.item_lore.replace(/§([1-9]|[a-l])|§/gm, '') : null;
48
+ /**
49
+ * Auctipn Item Lore as it is from the API
50
+ * @type {string}
51
+ */
52
+ this.itemLoreRaw = data.item_lore || null;
53
+ /**
54
+ * Rarity of Item
55
+ * @type {Rarity}
56
+ */
57
+ this.rarity = data.tier || null;
58
+ /**
59
+ * Auction starting bid, or price for BIN
60
+ * @type {number}
61
+ */
62
+ this.startingBid = data.starting_bid || 0;
63
+ /**
64
+ * Auction's highest bid, if it is bidded or price for BIN
65
+ * @type {number}
66
+ */
67
+ this.highestBid = this.bin ? data.starting_bid : data.highest_bid_amount || 0;
68
+ /**
69
+ * Auction bids
70
+ * @type {Bid[]}
71
+ */
72
+ this.bids = data.bids.length ? data.bids.map((b) => new Bid(b)) : [];
73
+ /**
74
+ * is Auction Claimed
75
+ * @type {boolean}
76
+ */
77
+ this.claimed = data.claimed || false;
78
+ /**
79
+ * Which bidders, if any, claimed
80
+ * @type {string[]}
81
+ */
82
+ this.claimedBidders = this.claimed ? data.claimed_bidders : [];
83
+ }
84
+ /**
85
+ * Item Name
86
+ * @return {string}
87
+ */
88
+ toString() {
89
+ return this.item;
90
+ }
91
+ }
92
+ /**
93
+ * @typedef {string} Rarity
94
+ * * `VERY_SPECIAL`
95
+ * * `SPECIAL`
96
+ * * `SUPREME`
97
+ * * `MYTHIC`
98
+ * * `LEGENDARY`
99
+ * * `EPIC`
100
+ * * `RARE`
101
+ * * `UNCOMMON`
102
+ * * `COMMON`
103
+ */
104
+ module.exports = Auction;