hypixel-api-reborn 11.2.0 → 11.3.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 (101) hide show
  1. package/README.md +1 -1
  2. package/eslint.config.mjs +71 -0
  3. package/package.json +14 -20
  4. package/src/API/getAchievements.js +1 -0
  5. package/src/API/getBoosters.js +1 -0
  6. package/src/API/getChallenges.js +1 -0
  7. package/src/API/getGameCounts.js +1 -0
  8. package/src/API/getGuild.js +4 -3
  9. package/src/API/getGuildAchievements.js +1 -0
  10. package/src/API/getLeaderboards.js +1 -1
  11. package/src/API/getPlayer.js +1 -0
  12. package/src/API/getQuests.js +1 -0
  13. package/src/API/getRecentGames.js +5 -9
  14. package/src/API/getServerInfo.js +40 -37
  15. package/src/API/getStatus.js +1 -0
  16. package/src/API/getWatchdogStats.js +1 -0
  17. package/src/API/housing/getActiveHouses.js +7 -0
  18. package/src/API/housing/getHouse.js +9 -0
  19. package/src/API/housing/getPlayerHouses.js +11 -0
  20. package/src/API/index.js +6 -1
  21. package/src/API/skyblock/getAuction.js +8 -6
  22. package/src/API/skyblock/getAuctions.js +15 -12
  23. package/src/API/skyblock/getAuctionsByPlayer.js +1 -1
  24. package/src/API/skyblock/getBazaar.js +1 -3
  25. package/src/API/skyblock/getBingo.js +1 -2
  26. package/src/API/skyblock/getBingoByPlayer.js +3 -3
  27. package/src/API/skyblock/getEndedAuctions.js +1 -0
  28. package/src/API/skyblock/getFireSales.js +1 -1
  29. package/src/API/skyblock/getGarden.js +7 -0
  30. package/src/API/skyblock/getGovernment.js +1 -2
  31. package/src/API/skyblock/getMember.js +5 -2
  32. package/src/API/skyblock/getMuseum.js +1 -0
  33. package/src/API/skyblock/getNews.js +1 -0
  34. package/src/API/skyblock/getProfiles.js +5 -2
  35. package/src/Client.js +88 -16
  36. package/src/Private/rateLimit.js +7 -11
  37. package/src/Private/requests.js +12 -13
  38. package/src/Private/updater.js +2 -3
  39. package/src/Private/uuidCache.js +1 -2
  40. package/src/Private/validate.js +19 -19
  41. package/src/index.js +5 -0
  42. package/src/structures/APIIncident.js +1 -2
  43. package/src/structures/APIStatus.js +0 -1
  44. package/src/structures/Boosters/Booster.js +9 -8
  45. package/src/structures/Game.js +1 -1
  46. package/src/structures/Guild/Guild.js +19 -36
  47. package/src/structures/Guild/GuildMember.js +2 -2
  48. package/src/structures/House.js +54 -0
  49. package/src/structures/MiniGames/Arcade.js +798 -312
  50. package/src/structures/MiniGames/ArenaBrawl.js +98 -32
  51. package/src/structures/MiniGames/BedWars.js +197 -194
  52. package/src/structures/MiniGames/BlitzSurvivalGames.js +381 -129
  53. package/src/structures/MiniGames/BuildBattle.js +19 -8
  54. package/src/structures/MiniGames/CopsAndCrims.js +253 -25
  55. package/src/structures/MiniGames/Duels.js +905 -664
  56. package/src/structures/MiniGames/MegaWalls.js +390 -51
  57. package/src/structures/MiniGames/MurderMystery.js +151 -30
  58. package/src/structures/MiniGames/Paintball.js +31 -11
  59. package/src/structures/MiniGames/Pit.js +4 -5
  60. package/src/structures/MiniGames/Quakecraft.js +113 -50
  61. package/src/structures/MiniGames/SkyWars.js +528 -372
  62. package/src/structures/MiniGames/SmashHeroes.js +201 -73
  63. package/src/structures/MiniGames/SpeedUHC.js +77 -24
  64. package/src/structures/MiniGames/TNTGames.js +242 -73
  65. package/src/structures/MiniGames/TurboKartRacers.js +55 -115
  66. package/src/structures/MiniGames/UHC.js +144 -132
  67. package/src/structures/MiniGames/VampireZ.js +70 -37
  68. package/src/structures/MiniGames/Warlords.js +126 -1
  69. package/src/structures/MiniGames/WoolWars.js +60 -9
  70. package/src/structures/Pet.js +1 -1
  71. package/src/structures/Player.js +43 -128
  72. package/src/structures/PlayerCosmetics.js +5 -4
  73. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +2 -1
  74. package/src/structures/SkyBlock/Auctions/BaseAuction.js +1 -1
  75. package/src/structures/SkyBlock/News/SkyblockNews.js +15 -15
  76. package/src/structures/SkyBlock/PlayerBingo.js +7 -14
  77. package/src/structures/SkyBlock/SkyblockGarden.js +146 -0
  78. package/src/structures/SkyBlock/SkyblockInventoryItem.js +4 -28
  79. package/src/structures/SkyBlock/SkyblockMember.js +90 -228
  80. package/src/structures/SkyBlock/SkyblockPet.js +3 -4
  81. package/src/structures/SkyBlock/Static/Bingo.js +10 -11
  82. package/src/structures/SkyBlock/Static/BingoData.js +1 -1
  83. package/src/structures/Static/Achievement.js +16 -15
  84. package/src/structures/Static/AchievementTier.js +2 -2
  85. package/src/structures/Static/Quest.js +2 -2
  86. package/src/utils/Constants.js +522 -520
  87. package/src/utils/{guildExp.js → Guild.js} +42 -12
  88. package/src/utils/Player.js +112 -0
  89. package/src/utils/SkyblockUtils.js +482 -192
  90. package/src/utils/arrayTools.js +1 -1
  91. package/src/utils/divide.js +1 -1
  92. package/src/utils/index.js +2 -1
  93. package/src/utils/isGuildID.js +1 -1
  94. package/src/utils/oscillation.js +4 -2
  95. package/src/utils/removeSnakeCase.js +11 -7
  96. package/src/utils/rgbToHexColor.js +1 -1
  97. package/src/utils/romanize.js +3 -3
  98. package/src/utils/toUuid.js +4 -4
  99. package/src/utils/varInt.js +2 -2
  100. package/typings/index.d.ts +1186 -967
  101. package/src/utils/toIGN.js +0 -24
package/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
 
24
24
  #### Requirements
25
25
 
26
- **For Node.js users >= v14.x.x** <br> **For TypeScript users >= v3.5**
26
+ **For Node.js users >= v18.18.0** <br> **For TypeScript users >= v3.5**
27
27
 
28
28
  ### Installation & Usage
29
29
 
@@ -0,0 +1,71 @@
1
+ import jsdoc from 'eslint-plugin-jsdoc';
2
+ import globals from 'globals';
3
+ import js from '@eslint/js';
4
+
5
+ export default [
6
+ js.configs.recommended,
7
+ {
8
+ ignores: ['docs/**', 'tests/**', 'node_modules/*'],
9
+ plugins: { jsdoc: jsdoc },
10
+ languageOptions: {
11
+ ecmaVersion: 2021,
12
+ sourceType: 'commonjs',
13
+ globals: {
14
+ ...globals.commonjs,
15
+ ...globals.es2021,
16
+ ...globals.node
17
+ }
18
+ },
19
+ rules: {
20
+ 'max-len': ['error', { code: 120, ignoreUrls: true, ignoreComments: true }],
21
+ 'no-constant-condition': ['error', { checkLoops: false }],
22
+ 'prefer-const': ['warn', { destructuring: 'all' }],
23
+ 'no-unused-vars': ['error', { args: 'none' }],
24
+ curly: ['warn', 'multi-line', 'consistent'],
25
+ 'logical-assignment-operators': 'warn',
26
+ 'no-template-curly-in-string': 'error',
27
+ 'quote-props': ['error', 'as-needed'],
28
+ 'jsdoc/no-undefined-types': 'warn',
29
+ 'comma-dangle': ['error', 'never'],
30
+ 'no-useless-constructor': 'error',
31
+ 'no-useless-assignment': 'error',
32
+ 'no-inner-declarations': 'error',
33
+ 'no-implicit-coercion': 'error',
34
+ 'jsdoc/require-jsdoc': 'error',
35
+ 'no-use-before-define': 'warn',
36
+ 'no-underscore-dangle': 'warn',
37
+ 'no-unneeded-ternary': 'error',
38
+ 'jsdoc/check-values': 'error',
39
+ 'default-param-last': 'error',
40
+ 'one-var': ['warn', 'never'],
41
+ 'no-inline-comments': 'warn',
42
+ 'jsdoc/valid-types': 'error',
43
+ 'no-empty-function': 'error',
44
+ 'no-useless-return': 'error',
45
+ 'no-useless-rename': 'warn',
46
+ 'no-useless-concat': 'warn',
47
+ 'no-throw-literal': 'error',
48
+ 'no-extend-native': 'error',
49
+ 'default-case-last': 'warn',
50
+ 'no-self-compare': 'error',
51
+ 'no-new-wrappers': 'error',
52
+ 'no-lone-blocks': 'error',
53
+ 'no-undef-init': 'error',
54
+ 'no-else-return': 'warn',
55
+ 'no-extra-semi': 'error',
56
+ 'require-await': 'warn',
57
+ yoda: ['error', 'always'],
58
+ 'default-case': 'error',
59
+ 'dot-notation': 'error',
60
+ 'no-sequences': 'warn',
61
+ 'no-multi-str': 'warn',
62
+ 'no-lonely-if': 'warn',
63
+ 'no-new-func': 'error',
64
+ 'no-console': 'error',
65
+ camelcase: 'warn',
66
+ 'no-var': 'warn',
67
+ eqeqeq: 'warn',
68
+ semi: 'error'
69
+ }
70
+ }
71
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypixel-api-reborn",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "description": "Feature-rich Hypixel API wrapper for Node.js",
5
5
  "main": "./src/index.js",
6
6
  "types": "./typings/index.d.ts",
@@ -16,26 +16,23 @@
16
16
  "url": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/issues"
17
17
  },
18
18
  "scripts": {
19
- "lint": "npx eslint src/ typings/",
20
- "lint:fix": "npx eslint src/ typings/ --fix",
21
- "lint:dev": "npm run eslint && npm run dtslint",
19
+ "lint": "npx eslint --cache src/",
20
+ "lint:fix": "npx eslint --cache src/ --fix",
22
21
  "tests": "npx mocha tests --exit --recursive",
23
- "docgen": "npx docgen -s src -o ./master.json",
24
- "dtslint": "npx dtslint typings",
25
- "prettier": "npx prettier --write src/ typings/",
26
- "prettier:check": "npx prettier --check src/ typings/"
22
+ "docgen": " npx docgen -s src/ --custom docs/index.yml -o ./master.json",
23
+ "prettier": "npx prettier --cache --write src/ typings/",
24
+ "prettier:check": "npx prettier --cache --check src/ typings/"
27
25
  },
28
26
  "engines": {
29
- "node": ">=14.0.0"
27
+ "node": ">=18.18.0"
30
28
  },
31
29
  "author": "StavZ",
32
30
  "dependencies": {
33
31
  "node-cache": "^5.1.2",
34
32
  "node-fetch": "^3.3.2",
35
- "object-path": "^0.11.8",
36
33
  "prismarine-nbt": "^2.5.0",
37
34
  "rss-parser": "^3.13.0",
38
- "skyhelper-networth": "^1.19.0"
35
+ "skyhelper-networth": "^1.21.0"
39
36
  },
40
37
  "license": "MIT",
41
38
  "readme": "https://hypixel.stavzdev.me/",
@@ -45,18 +42,15 @@
45
42
  "publisher": "StavZ",
46
43
  "devDependencies": {
47
44
  "@discordjs/docgen": "github:discordjs/docgen",
48
- "@types/node": "^20.11.19",
49
- "@typescript-eslint/eslint-plugin": "^7.0.2",
50
- "@typescript-eslint/parser": "^7.0.2",
45
+ "@types/node": "^20.14.11",
51
46
  "chai": "^4.3.4",
52
- "dtslint": "^4.2.1",
53
- "eslint": "^8.56.0",
54
- "eslint-config-google": "^0.14.0",
55
- "eslint-config-prettier": "^9.1.0",
47
+ "eslint": "^9.7.0",
48
+ "eslint-plugin-jsdoc": "^48.8.3",
49
+ "globals": "^15.8.0",
56
50
  "mocha": "^10.4.0",
57
51
  "node-env-run": "^4.0.2",
58
52
  "path": "^0.12.7",
59
- "prettier": "^3.2.5",
60
- "typescript": "^5.3.3"
53
+ "prettier": "^3.3.3",
54
+ "typescript": "^5.5.3"
61
55
  }
62
56
  }
@@ -1,5 +1,6 @@
1
1
  module.exports = async function () {
2
2
  const Achievements = require('../structures/Static/Achievements');
3
+ // eslint-disable-next-line no-underscore-dangle
3
4
  const res = await this._makeRequest('/resources/achievements');
4
5
  if (res.raw) return res;
5
6
  return new Achievements(res);
@@ -1,5 +1,6 @@
1
1
  module.exports = async function () {
2
2
  const Booster = require('../structures/Boosters/Booster');
3
+ // eslint-disable-next-line no-underscore-dangle
3
4
  const res = await this._makeRequest('/boosters');
4
5
  if (res.raw) return res;
5
6
  return res.boosters.length ? res.boosters.map((b) => new Booster(b)).reverse() : [];
@@ -1,5 +1,6 @@
1
1
  module.exports = async function () {
2
2
  const Challenges = require('../structures/Static/Challenges');
3
+ // eslint-disable-next-line no-underscore-dangle
3
4
  const res = await this._makeRequest('/resources/challenges');
4
5
  if (res.raw) return res;
5
6
  return new Challenges(res);
@@ -1,5 +1,6 @@
1
1
  const GameCounts = require('../structures/GameCounts');
2
2
  module.exports = async function () {
3
+ // eslint-disable-next-line no-underscore-dangle
3
4
  const res = await this._makeRequest('/counts');
4
5
  if (res.raw) return res;
5
6
  return new GameCounts(res);
@@ -4,13 +4,14 @@ const isGuildID = require('../utils/isGuildID');
4
4
  module.exports = async function (searchParameter, query) {
5
5
  if (!query) throw new Error(Errors.NO_GUILD_QUERY);
6
6
  const Guild = require('../structures/Guild/Guild');
7
- if (searchParameter === 'id' && !isGuildID(query)) throw new Error(Errors.INVALID_GUILD_ID);
8
- const isPlayerQuery = searchParameter === 'player';
7
+ if ('id' === searchParameter && !isGuildID(query)) throw new Error(Errors.INVALID_GUILD_ID);
8
+ const isPlayerQuery = 'player' === searchParameter;
9
9
  if (isPlayerQuery) query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
10
10
  if (!['id', 'name', 'player'].includes(searchParameter)) throw new Error(Errors.INVALID_GUILD_SEARCH_PARAMETER);
11
+ // eslint-disable-next-line no-underscore-dangle
11
12
  const res = await this._makeRequest(`/guild?${searchParameter}=${encodeURI(query)}`);
12
13
  if (res.raw) return res;
13
- if (!res.guild && searchParameter !== 'player') {
14
+ if (!res.guild && 'player' !== searchParameter) {
14
15
  throw new Error(Errors.GUILD_DOES_NOT_EXIST);
15
16
  }
16
17
 
@@ -1,5 +1,6 @@
1
1
  module.exports = async function () {
2
2
  const GuildAchievements = require('../structures/Static/GuildAchievements');
3
+ // eslint-disable-next-line no-underscore-dangle
3
4
  const res = await this._makeRequest('/resources/guilds/achievements');
4
5
  if (res.raw) return res;
5
6
  return new GuildAchievements(res);
@@ -1,11 +1,11 @@
1
1
  const Errors = require('../Errors');
2
2
  module.exports = async function () {
3
3
  const Leaderboard = require('../structures/Leaderboard');
4
+ // eslint-disable-next-line no-underscore-dangle
4
5
  const res = await this._makeRequest('/leaderboards');
5
6
  if (res.raw) return res;
6
7
  if (!res.leaderboards) throw new Error(Errors.SOMETHING_WENT_WRONG.replace(/{cause}/, 'Try again.'));
7
8
  const lbnames = Object.create(require('../utils/Constants').leaderboardNames);
8
- // eslint-disable-next-line guard-for-in
9
9
  for (const name in lbnames) {
10
10
  lbnames[name] = res.leaderboards[lbnames[name]].length
11
11
  ? res.leaderboards[lbnames[name]].map((lb) => new Leaderboard(lb))
@@ -6,6 +6,7 @@ module.exports = async function (query, options = { guild: false, recentGames: f
6
6
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
7
7
  const Player = require('../structures/Player');
8
8
  query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
9
+ // eslint-disable-next-line no-underscore-dangle
9
10
  const res = await this._makeRequest(`/player?uuid=${query}`);
10
11
  if (res.raw) return res;
11
12
  if (query && !res.player) throw new Error(Errors.PLAYER_HAS_NEVER_LOGGED);
@@ -1,5 +1,6 @@
1
1
  module.exports = async function () {
2
2
  const Quests = require('../structures/Static/Quests');
3
+ // eslint-disable-next-line no-underscore-dangle
3
4
  const res = await this._makeRequest('/resources/quests');
4
5
  if (res.raw) return res;
5
6
  return new Quests(res);
@@ -1,18 +1,14 @@
1
- const Errors = require('../Errors');
2
1
  const toUuid = require('../utils/toUuid');
3
- const day3 = 1000 * 60 * 60 * 24 * 3;
4
- module.exports = async function (query, playerData) {
2
+ const Errors = require('../Errors');
3
+ module.exports = async function (query) {
5
4
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
6
5
  const RecentGame = require('../structures/RecentGame');
7
-
8
6
  query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
9
-
7
+ // eslint-disable-next-line no-underscore-dangle
10
8
  const res = await this._makeRequest(`/recentgames?uuid=${query}`);
11
9
  if (res.raw) return res;
12
- if (res.games === []) {
13
- if (!playerData) throw new Error(Errors.PLAYER_IS_INACTIVE);
14
- if (Date.now() - playerData.lastLogoutTimestamp < day3) throw new Error(Errors.PLAYER_DISABLED_ENDPOINT);
15
- throw new Error(Errors.PLAYER_IS_INACTIVE);
10
+ if (0 === res.games.length) {
11
+ return [];
16
12
  }
17
13
  return res.games.map((x) => new RecentGame(x));
18
14
  };
@@ -1,13 +1,43 @@
1
- const net = require('net');
2
- const Errors = require('../Errors');
1
+ /* eslint-disable jsdoc/require-jsdoc */
3
2
  const ServerInfo = require('../structures/ServerInfo');
4
3
  const varInt = require('../utils/varInt');
4
+ const Errors = require('../Errors');
5
+ const net = require('net');
5
6
  const packetsToSend = ['1500E0050E6D632E6879706978656C2E6E657463DD01', '0100', '09010000000000000000'].map((x) =>
7
+ // To avoid dependency hell, these are precompiled as hex.
6
8
  Buffer.from(x, 'hex')
7
- ); // To avoid dependency hell, these are precompiled as hex.
9
+ );
10
+
11
+ async function ping(cli) {
12
+ await cli.write(packetsToSend[2]);
13
+ const time = Date.now();
14
+ return new Promise((resolve) => {
15
+ cli.once('data', () => {
16
+ resolve(Date.now() - time);
17
+ });
18
+ });
19
+ }
20
+
21
+ async function getPing(amount, cli) {
22
+ let pingSum = 0;
23
+ for (let i = 0; i < amount; i++) {
24
+ pingSum += await ping(cli);
25
+ }
26
+ cli.destroy();
27
+ return Math.round(pingSum / amount);
28
+ }
29
+
30
+ function parseData(stringJson, ping) {
31
+ try {
32
+ return new ServerInfo(JSON.parse(stringJson), ping);
33
+ } catch {
34
+ return undefined;
35
+ }
36
+ }
37
+
8
38
  module.exports = async function (repeats) {
9
- if (repeats < 0 || typeof repeats !== 'number') repeats = 3;
10
- if (repeats > 10) repeats = 10;
39
+ if (0 > repeats || 'number' !== typeof repeats) repeats = 3;
40
+ if (10 < repeats) repeats = 10;
11
41
  let aggregatedData = '';
12
42
  let dataLength = 0;
13
43
  return await new Promise((resolve, reject) => {
@@ -20,7 +50,7 @@ module.exports = async function (repeats) {
20
50
  });
21
51
  cli.on('data', async (data) => {
22
52
  if (!aggregatedData) {
23
- const varIntBorder = data.findIndex((x) => x === 0x00) + 1;
53
+ const varIntBorder = data.findIndex((x) => 0x00 === x) + 1;
24
54
  dataLength = varInt(
25
55
  data
26
56
  .toString('hex', 0, varIntBorder)
@@ -29,40 +59,13 @@ module.exports = async function (repeats) {
29
59
  );
30
60
  dataLength -= varIntBorder * 8;
31
61
  aggregatedData += data.toString('utf-8', 5);
32
- } else aggregatedData += data.toString('utf-8');
62
+ } else {
63
+ aggregatedData += data.toString('utf-8');
64
+ }
33
65
 
34
66
  if (dataLength >= aggregatedData.length) return;
35
- cli.removeAllListeners('data'); // Remove this listener
67
+ cli.removeAllListeners('data');
36
68
  resolve(parseData(aggregatedData, await getPing(repeats, cli)));
37
69
  });
38
70
  });
39
71
  };
40
- // eslint-disable-next-line require-jsdoc
41
- async function getPing(amount, cli) {
42
- let pingSum = 0;
43
- for (let i = 0; i < amount; i++) {
44
- pingSum += await ping(cli);
45
- }
46
- cli.destroy();
47
- return Math.round(pingSum / amount);
48
- }
49
-
50
- // eslint-disable-next-line require-jsdoc
51
- async function ping(cli) {
52
- await cli.write(packetsToSend[2]);
53
- const time = Date.now();
54
- return new Promise((resolve) => {
55
- cli.once('data', () => {
56
- resolve(Date.now() - time);
57
- });
58
- });
59
- }
60
-
61
- // eslint-disable-next-line require-jsdoc
62
- function parseData(stringJson, ping) {
63
- try {
64
- return new ServerInfo(JSON.parse(stringJson), ping);
65
- } catch (e) {
66
- return undefined;
67
- }
68
- }
@@ -2,6 +2,7 @@ const toUuid = require('../utils/toUuid');
2
2
  module.exports = async function (query) {
3
3
  const Status = require('../structures/Status');
4
4
  query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
5
+ // eslint-disable-next-line no-underscore-dangle
5
6
  const res = await this._makeRequest(`/status?uuid=${query}`);
6
7
  if (res.raw) return res;
7
8
  return new Status(res.session);
@@ -1,5 +1,6 @@
1
1
  module.exports = async function () {
2
2
  const WatchdogStats = require('../structures/Watchdog/Stats');
3
+ // eslint-disable-next-line no-underscore-dangle
3
4
  const res = await this._makeRequest('/punishmentstats');
4
5
  if (res.raw) return res;
5
6
  return new WatchdogStats(res);
@@ -0,0 +1,7 @@
1
+ module.exports = async function () {
2
+ const House = require('../../structures/House');
3
+ // eslint-disable-next-line no-underscore-dangle
4
+ const res = await this._makeRequest('/housing/active');
5
+ if (res.raw) return res;
6
+ return res.length ? res.map((b) => new House(b)) : [];
7
+ };
@@ -0,0 +1,9 @@
1
+ const Errors = require('../../Errors');
2
+ module.exports = async function (query) {
3
+ if (!query) throw new Error(Errors.NO_UUID);
4
+ const House = require('../../structures/House');
5
+ // eslint-disable-next-line no-underscore-dangle
6
+ const res = await this._makeRequest(`/housing/house?house=${query}`);
7
+ if (res.raw) return res;
8
+ return new House(res);
9
+ };
@@ -0,0 +1,11 @@
1
+ const Errors = require('../../Errors');
2
+ const toUuid = require('../../utils/toUuid');
3
+ module.exports = async function (query) {
4
+ if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
5
+ query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
6
+ const House = require('../../structures/House');
7
+ // eslint-disable-next-line no-underscore-dangle
8
+ const res = await this._makeRequest(`/housing/houses?player=${query}`);
9
+ if (res.raw) return res;
10
+ return res.length ? res.map((b) => new House(b)) : [];
11
+ };
package/src/API/index.js CHANGED
@@ -22,9 +22,14 @@ module.exports = {
22
22
  getSkyblockBingoByPlayer: require('./skyblock/getBingoByPlayer.js'),
23
23
  getSkyblockEndedAuctions: require('./skyblock/getEndedAuctions.js'),
24
24
  getSkyblockFireSales: require('./skyblock/getFireSales.js'),
25
+ getSkyblockGarden: require('./skyblock/getGarden.js'),
25
26
  getSkyblockGovernment: require('./skyblock/getGovernment.js'),
26
27
  getSkyblockMember: require('./skyblock/getMember.js'),
27
28
  getSkyblockMuseum: require('./skyblock/getMuseum.js'),
28
29
  getSkyblockNews: require('./skyblock/getNews.js'),
29
- getSkyblockProfiles: require('./skyblock/getProfiles.js')
30
+ getSkyblockProfiles: require('./skyblock/getProfiles.js'),
31
+
32
+ getActiveHouses: require('./housing/getActiveHouses.js'),
33
+ getPlayerHouses: require('./housing/getPlayerHouses.js'),
34
+ getHouse: require('./housing/getHouse.js')
30
35
  };
@@ -3,17 +3,19 @@ const toUuid = require('../../utils/toUuid');
3
3
  module.exports = async function (type, query, includeItemBytes = false) {
4
4
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
5
5
  const Auction = require('../../structures/SkyBlock/Auctions/Auction');
6
- let filter = '';
7
- if (type === 'PROFILE') {
6
+ let filter;
7
+ if ('PROFILE' === type) {
8
8
  filter = 'profile';
9
- } else if (type === 'PLAYER') {
9
+ } else if ('PLAYER' === type) {
10
10
  query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
11
11
  filter = 'player';
12
- } else if (type === 'AUCTION') {
12
+ } else if ('AUCTION' === type) {
13
13
  filter = 'uuid';
14
- } else throw new Error(Errors.BAD_AUCTION_FILTER);
14
+ } else {
15
+ throw new Error(Errors.BAD_AUCTION_FILTER);
16
+ }
17
+ // eslint-disable-next-line no-underscore-dangle
15
18
  const res = await this._makeRequest(`/skyblock/auction?${filter}=${query}`);
16
19
  if (res.raw) return res;
17
-
18
20
  return res.auctions.length ? res.auctions.map((a) => new Auction(a, includeItemBytes)) : [];
19
21
  };
@@ -1,10 +1,10 @@
1
- /* eslint-disable require-jsdoc */
1
+ /* eslint-disable jsdoc/require-jsdoc */
2
2
  const Auction = require('../../structures/SkyBlock/Auctions/Auction');
3
3
  const AuctionInfo = require('../../structures/SkyBlock/Auctions/AuctionInfo');
4
4
  const Errors = require('../../Errors');
5
- let _makeRequest;
6
5
  async function getPage(page = 0, options = {}) {
7
- const content = await _makeRequest(`/skyblock/auctions?page=${page}`, false);
6
+ // eslint-disable-next-line no-underscore-dangle
7
+ const content = await this._makeRequest(`/skyblock/auctions?page=${page}`, false);
8
8
  const result = {};
9
9
  if (!options.noInfo) result.info = new AuctionInfo(content);
10
10
  if (options.raw) result.auctions = content.auctions;
@@ -16,24 +16,24 @@ async function noReject(promise, args = [], retries = 3, cooldown = 100) {
16
16
  try {
17
17
  const result = await promise.call(null, ...args);
18
18
  return result;
19
- } catch (e) {
19
+ } catch {
20
20
  if (retries) {
21
21
  await new Promise((resolve) => setTimeout(resolve, cooldown));
22
22
  return await noReject(promise, args, retries - 1, cooldown);
23
- } else return null;
23
+ }
24
+ return null;
24
25
  }
25
26
  }
26
27
  module.exports = async function (range, options = {}) {
27
- _makeRequest = this._makeRequest;
28
- options.retries = options.retries || 3;
29
- options.cooldown = options.cooldown || 100;
30
- if (range == null || range === '*') range = [0, (await getPage(0, { noAuctions: true })).info.totalPages];
28
+ options.retries ||= 3;
29
+ options.cooldown ||= 100;
30
+ if (null === range || '*' === range) range = [0, (await getPage(0, { noAuctions: true })).info.totalPages];
31
31
  if (!Array.isArray(range)) range = [parseInt(range), parseInt(range)];
32
32
  if (isNaN(range[0])) throw new Error(Errors.PAGE_INDEX_ERROR);
33
- if (parseInt(options.retries) !== options.retries || options.retries > 10 || options.retries < 0) {
33
+ if (parseInt(options.retries) !== options.retries || 10 < options.retries || 0 > options.retries) {
34
34
  throw new Error(Errors.INVALID_OPTION_VALUE);
35
35
  }
36
- if (parseInt(options.cooldown) !== options.cooldown || options.cooldown > 3000 || options.cooldown < 0) {
36
+ if (parseInt(options.cooldown) !== options.cooldown || 3000 < options.cooldown || 0 > options.cooldown) {
37
37
  throw new Error(Errors.INVALID_OPTION_VALUE);
38
38
  }
39
39
  range = range.sort();
@@ -49,7 +49,9 @@ module.exports = async function (range, options = {}) {
49
49
  if (resp) {
50
50
  result.auctions = result.auctions.concat(resp.auctions);
51
51
  if (resp.info) result.info = resp.info;
52
- } else failedPages.push(i);
52
+ } else {
53
+ failedPages.push(i);
54
+ }
53
55
  }
54
56
  }
55
57
  if (fetches.length) {
@@ -63,6 +65,7 @@ module.exports = async function (range, options = {}) {
63
65
  return pV;
64
66
  }, []);
65
67
  }
68
+ // eslint-disable-next-line no-underscore-dangle
66
69
  result.info = result.info ? result.info._extend('failedPages', failedPages) : { failedPages };
67
70
  return result;
68
71
  };
@@ -4,8 +4,8 @@ module.exports = async function (query, includeItemBytes = false) {
4
4
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
5
5
  const Auction = require('../../structures/SkyBlock/Auctions/Auction');
6
6
  query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
7
+ // eslint-disable-next-line no-underscore-dangle
7
8
  const res = await this._makeRequest(`/skyblock/auction?player=${query}`);
8
9
  if (res.raw) return res;
9
-
10
10
  return res.auctions.length ? res.auctions.map((a) => new Auction(a, includeItemBytes)) : [];
11
11
  };
@@ -1,10 +1,8 @@
1
1
  module.exports = async function () {
2
2
  const Product = require('../../structures/SkyBlock/Bazzar/Product');
3
-
3
+ // eslint-disable-next-line no-underscore-dangle
4
4
  const res = await this._makeRequest('/skyblock/bazaar');
5
5
  if (res.raw) return res;
6
-
7
6
  const productsKeys = Object.keys(res.products);
8
-
9
7
  return productsKeys.map((x) => new Product(res.products[x]));
10
8
  };
@@ -1,8 +1,7 @@
1
1
  module.exports = async function () {
2
2
  const BingoData = require('../../structures/SkyBlock/Static/BingoData');
3
-
3
+ // eslint-disable-next-line no-underscore-dangle
4
4
  const res = await this._makeRequest('/resources/skyblock/bingo');
5
5
  if (res.raw) return res;
6
-
7
6
  return new BingoData(res);
8
7
  };
@@ -1,14 +1,14 @@
1
- const getBingo = require('./getBingo');
2
1
  const toUuid = require('../../utils/toUuid');
2
+ const getBingo = require('./getBingo');
3
3
  const Errors = require('../../Errors');
4
4
  module.exports = async function (query, { fetchBingoData = false }) {
5
5
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
6
6
  const PlayerBingo = require('../../structures/SkyBlock/PlayerBingo');
7
7
  query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
8
+ // eslint-disable-next-line no-underscore-dangle
8
9
  const res = await this._makeRequest(`/skyblock/uuid?player=${query}`);
9
10
  if (res.raw) return res;
10
11
  let bingoData = null;
11
12
  if (fetchBingoData) bingoData = await getBingo.call(this);
12
-
13
- return new PlayerBingo(data, bingoData);
13
+ return new PlayerBingo(res, bingoData);
14
14
  };
@@ -1,6 +1,7 @@
1
1
  const PartialAuction = require('../../structures/SkyBlock/Auctions/PartialAuction');
2
2
  const AuctionInfo = require('../../structures/SkyBlock/Auctions/AuctionInfo');
3
3
  module.exports = async function (includeItemBytes = false) {
4
+ // eslint-disable-next-line no-underscore-dangle
4
5
  const res = await this._makeRequest('/skyblock/auctions_ended', false);
5
6
  if (res.raw) return res;
6
7
  return {
@@ -1,7 +1,7 @@
1
1
  module.exports = async function () {
2
2
  const FireSale = require('../../structures/SkyBlock/Static/FireSale');
3
+ // eslint-disable-next-line no-underscore-dangle
3
4
  const res = await this._makeRequest('/skyblock/firesales');
4
5
  if (res.raw) return res;
5
-
6
6
  return res.sales.length ? res.sales.map((a) => new FireSale(a)) : [];
7
7
  };
@@ -0,0 +1,7 @@
1
+ module.exports = async function (profileId) {
2
+ const SkyblockGarden = require('../../structures/SkyBlock/SkyblockGarden');
3
+ // eslint-disable-next-line no-underscore-dangle
4
+ const res = await this._makeRequest(`/skyblock/garden?profile=${profileId}`);
5
+ if (res.raw) return res;
6
+ return new SkyblockGarden(res);
7
+ };
@@ -1,8 +1,7 @@
1
1
  module.exports = async function () {
2
2
  const GovernmentData = require('../../structures/SkyBlock/Static/Government.js');
3
-
3
+ // eslint-disable-next-line no-underscore-dangle
4
4
  const res = await this._makeRequest('/resources/skyblock/election');
5
5
  if (res.raw) return res;
6
-
7
6
  return new GovernmentData(res);
8
7
  };
@@ -1,11 +1,13 @@
1
1
  const Errors = require('../../Errors');
2
2
  const toUuid = require('../../utils/toUuid');
3
3
  const getPlayer = require('../getPlayer');
4
- module.exports = async function (query, options = { fetchPlayer: false, getMuseum: false }) {
4
+ module.exports = async function (query, options = { fetchPlayer: false, getMuseum: false, getGarden: false }) {
5
5
  const SkyblockMember = require('../../structures/SkyBlock/SkyblockMember');
6
- const getSkyblockMuseum = require('../skyblock/getMuseum');
6
+ const getSkyblockMuseum = require('./getMuseum');
7
+ const getSkyblockGarden = require('./getGarden');
7
8
  if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
8
9
  query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
10
+ // eslint-disable-next-line no-underscore-dangle
9
11
  const res = await this._makeRequest(`/skyblock/profiles?uuid=${query}`);
10
12
  if (res.raw) return res;
11
13
  if (!res.profiles || !res.profiles.length) throw new Error(Errors.NO_SKYBLOCK_PROFILES);
@@ -24,6 +26,7 @@ module.exports = async function (query, options = { fetchPlayer: false, getMuseu
24
26
  banking: profile.banking,
25
27
  communityUpgrades: profile.community_upgrades,
26
28
  museum: options.getMuseum ? await getSkyblockMuseum.call(this, query, profile.profile_id) : null,
29
+ garden: options.getGarden ? await getSkyblockGarden.call(this, profile.profile_id) : null,
27
30
  selected: profile.selected
28
31
  })
29
32
  );