hypixel-api-reborn 11.1.0 → 11.2.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.
- package/.prettierrc +3 -3
- package/README.md +5 -3
- package/package.json +20 -18
- package/src/API/getAchievements.js +6 -0
- package/src/API/getChallenges.js +6 -0
- package/src/API/getGuild.js +1 -1
- package/src/API/getGuildAchievements.js +6 -0
- package/src/API/getLeaderboards.js +3 -1
- package/src/API/getPlayer.js +1 -1
- package/src/API/getQuests.js +6 -0
- package/src/API/getRecentGames.js +1 -1
- package/src/API/getServerInfo.js +3 -1
- package/src/API/getStatus.js +1 -1
- package/src/API/index.js +28 -17
- package/src/API/skyblock/getAuction.js +19 -0
- package/src/API/skyblock/{getSkyblockAuctions.js → getAuctions.js} +6 -2
- package/src/API/skyblock/{getSkyblockAuctionsByPlayer.js → getAuctionsByPlayer.js} +1 -1
- package/src/API/skyblock/getBingo.js +8 -0
- package/src/API/skyblock/getBingoByPlayer.js +14 -0
- package/src/API/skyblock/getFireSales.js +7 -0
- package/src/API/skyblock/getGovernment.js +8 -0
- package/src/API/skyblock/{getSkyblockMember.js → getMember.js} +9 -3
- package/src/API/skyblock/getMuseum.js +14 -0
- package/src/API/skyblock/{getSkyblockProfiles.js → getProfiles.js} +13 -7
- package/src/Client.js +88 -14
- package/src/Errors.js +38 -17
- package/src/Private/rateLimit.js +10 -2
- package/src/Private/requests.js +19 -7
- package/src/Private/updater.js +9 -5
- package/src/Private/uuidCache.js +23 -29
- package/src/Private/validate.js +20 -9
- package/src/index.js +9 -0
- package/src/structures/APIIncident.js +3 -9
- package/src/structures/Boosters/Booster.js +5 -5
- package/src/structures/Color.js +93 -48
- package/src/structures/Game.js +3 -1
- package/src/structures/Guild/Guild.js +21 -17
- package/src/structures/Guild/GuildMember.js +6 -6
- package/src/structures/Guild/GuildRank.js +2 -2
- package/src/structures/MiniGames/Arcade.js +22 -17
- package/src/structures/MiniGames/BedWars.js +152 -24
- package/src/structures/MiniGames/Duels.js +84 -23
- package/src/structures/MiniGames/MegaWalls.js +3 -1
- package/src/structures/MiniGames/MurderMystery.js +2 -2
- package/src/structures/MiniGames/Pit.js +231 -2
- package/src/structures/MiniGames/PitInventoryItem.js +43 -0
- package/src/structures/MiniGames/SkyWars.js +19 -14
- package/src/structures/MiniGames/SmashHeroes.js +1 -1
- package/src/structures/MiniGames/TNTGames.js +1 -1
- package/src/structures/MiniGames/UHC.js +21 -3
- package/src/structures/Player.js +16 -20
- package/src/structures/PlayerCosmetics.js +64 -10
- package/src/structures/ServerInfo.js +1 -1
- package/src/structures/SkyBlock/Auctions/Auction.js +3 -1
- package/src/structures/SkyBlock/Auctions/AuctionInfo.js +1 -0
- package/src/structures/SkyBlock/Auctions/BaseAuction.js +1 -0
- package/src/structures/SkyBlock/Auctions/Bid.js +1 -0
- package/src/structures/SkyBlock/Auctions/PartialAuction.js +1 -0
- package/src/structures/SkyBlock/PlayerBingo.js +56 -0
- package/src/structures/SkyBlock/SkyblockInventoryItem.js +86 -18
- package/src/structures/SkyBlock/SkyblockMember.js +252 -144
- package/src/structures/SkyBlock/SkyblockMuseum.js +60 -0
- package/src/structures/SkyBlock/SkyblockMuseumItem.js +54 -0
- package/src/structures/SkyBlock/SkyblockPet.js +1 -0
- package/src/structures/SkyBlock/SkyblockProfile.js +37 -23
- package/src/structures/SkyBlock/Static/Bingo.js +102 -0
- package/src/structures/SkyBlock/Static/BingoData.js +45 -0
- package/src/structures/SkyBlock/Static/Candidate.js +40 -0
- package/src/structures/SkyBlock/Static/FireSale.js +55 -0
- package/src/structures/SkyBlock/Static/Government.js +74 -0
- package/src/structures/SkyBlock/Static/Perk.js +24 -0
- package/src/structures/Static/Achievement.js +86 -0
- package/src/structures/Static/AchievementTier.js +33 -0
- package/src/structures/Static/Achievements.js +30 -0
- package/src/structures/Static/Challenges.js +29 -0
- package/src/structures/Static/GameAchievements.js +36 -0
- package/src/structures/Static/GameChallenges.js +40 -0
- package/src/structures/Static/GameQuests.js +24 -0
- package/src/structures/Static/GuildAchievements.js +34 -0
- package/src/structures/Static/Quest.js +66 -0
- package/src/structures/Static/Quests.js +31 -0
- package/src/structures/Status.js +2 -2
- package/src/utils/Constants.js +382 -41
- package/src/utils/SkyblockUtils.js +12 -7
- package/src/utils/guildExp.js +4 -1
- package/src/utils/removeSnakeCase.js +9 -2
- package/src/utils/romanize.js +32 -1
- package/src/utils/toIGN.js +6 -2
- package/src/utils/toUuid.js +10 -5
- package/typings/index.d.ts +985 -295
- /package/src/API/skyblock/{getSkyblockBazaar.js → getBazaar.js} +0 -0
- /package/src/API/skyblock/{getEndedSkyblockAuctions.js → getEndedAuctions.js} +0 -0
- /package/src/API/skyblock/{getSkyblockNews.js → getNews.js} +0 -0
package/.prettierrc
CHANGED
package/README.md
CHANGED
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
|
|
16
16
|
### Links
|
|
17
17
|
|
|
18
|
-
[Discord Support](https://discord.gg/NSEBNMM) | [Documentation](https://hypixel-api-reborn.github.io/) |
|
|
19
|
-
[
|
|
18
|
+
[Discord Support](https://discord.gg/NSEBNMM) | [Documentation](https://hypixel-api-reborn.github.io/) |
|
|
19
|
+
[NPM](https://www.npmjs.com/package/hypixel-api-reborn) |
|
|
20
|
+
[GitHub](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn) |
|
|
21
|
+
[ToDo](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/projects/1) |
|
|
22
|
+
[CLI](https://github.com/Hypixel-API-Reborn/cli)
|
|
20
23
|
|
|
21
24
|
#### Requirements
|
|
22
25
|
|
|
@@ -31,7 +34,6 @@ npm i hypixel-api-reborn
|
|
|
31
34
|
```js
|
|
32
35
|
const Hypixel = require('hypixel-api-reborn');
|
|
33
36
|
const hypixel = new Hypixel.Client('API-KEY');
|
|
34
|
-
// https://stavzdev.is-inside.me/cCMiZdoy.gif
|
|
35
37
|
|
|
36
38
|
// getPlayer
|
|
37
39
|
hypixel
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypixel-api-reborn",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.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,12 +16,11 @@
|
|
|
16
16
|
"url": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/issues"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"lint": "npx eslint src/ typings/",
|
|
20
|
+
"lint:fix": "npx eslint src/ typings/ --fix",
|
|
21
21
|
"lint:dev": "npm run eslint && npm run dtslint",
|
|
22
|
-
"
|
|
23
|
-
"docgen": "npx docgen -s src -o
|
|
24
|
-
"docgen:custom": "npx docgen -s src --custom docs/index.yml -o ../docs/master.json",
|
|
22
|
+
"tests": "npx mocha tests --exit --recursive",
|
|
23
|
+
"docgen": "npx docgen -s src -o ./master.json",
|
|
25
24
|
"dtslint": "npx dtslint typings",
|
|
26
25
|
"prettier": "npx prettier --write src/ typings/",
|
|
27
26
|
"prettier:check": "npx prettier --check src/ typings/"
|
|
@@ -31,10 +30,12 @@
|
|
|
31
30
|
},
|
|
32
31
|
"author": "StavZ",
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"node-
|
|
33
|
+
"node-cache": "^5.1.2",
|
|
34
|
+
"node-fetch": "^3.3.2",
|
|
35
35
|
"object-path": "^0.11.8",
|
|
36
|
-
"prismarine-nbt": "^2.
|
|
37
|
-
"rss-parser": "^3.13.0"
|
|
36
|
+
"prismarine-nbt": "^2.5.0",
|
|
37
|
+
"rss-parser": "^3.13.0",
|
|
38
|
+
"skyhelper-networth": "^1.19.0"
|
|
38
39
|
},
|
|
39
40
|
"license": "MIT",
|
|
40
41
|
"readme": "https://hypixel.stavzdev.me/",
|
|
@@ -43,18 +44,19 @@
|
|
|
43
44
|
},
|
|
44
45
|
"publisher": "StavZ",
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@typescript-eslint/
|
|
47
|
+
"@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",
|
|
49
51
|
"chai": "^4.3.4",
|
|
50
|
-
"dtslint": "^4.1
|
|
51
|
-
"eslint": "^
|
|
52
|
+
"dtslint": "^4.2.1",
|
|
53
|
+
"eslint": "^8.56.0",
|
|
52
54
|
"eslint-config-google": "^0.14.0",
|
|
53
|
-
"eslint-config-prettier": "^9.
|
|
54
|
-
"mocha": "^
|
|
55
|
+
"eslint-config-prettier": "^9.1.0",
|
|
56
|
+
"mocha": "^10.4.0",
|
|
55
57
|
"node-env-run": "^4.0.2",
|
|
56
58
|
"path": "^0.12.7",
|
|
57
|
-
"prettier": "^3.
|
|
58
|
-
"typescript": "^
|
|
59
|
+
"prettier": "^3.2.5",
|
|
60
|
+
"typescript": "^5.3.3"
|
|
59
61
|
}
|
|
60
62
|
}
|
package/src/API/getGuild.js
CHANGED
|
@@ -6,7 +6,7 @@ module.exports = async function (searchParameter, query) {
|
|
|
6
6
|
const Guild = require('../structures/Guild/Guild');
|
|
7
7
|
if (searchParameter === 'id' && !isGuildID(query)) throw new Error(Errors.INVALID_GUILD_ID);
|
|
8
8
|
const isPlayerQuery = searchParameter === 'player';
|
|
9
|
-
if (isPlayerQuery) query = await toUuid(query);
|
|
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
11
|
const res = await this._makeRequest(`/guild?${searchParameter}=${encodeURI(query)}`);
|
|
12
12
|
if (res.raw) return res;
|
|
@@ -7,7 +7,9 @@ module.exports = async function () {
|
|
|
7
7
|
const lbnames = Object.create(require('../utils/Constants').leaderboardNames);
|
|
8
8
|
// eslint-disable-next-line guard-for-in
|
|
9
9
|
for (const name in lbnames) {
|
|
10
|
-
lbnames[name] = res.leaderboards[lbnames[name]].length
|
|
10
|
+
lbnames[name] = res.leaderboards[lbnames[name]].length
|
|
11
|
+
? res.leaderboards[lbnames[name]].map((lb) => new Leaderboard(lb))
|
|
12
|
+
: [];
|
|
11
13
|
}
|
|
12
14
|
return lbnames;
|
|
13
15
|
};
|
package/src/API/getPlayer.js
CHANGED
|
@@ -5,7 +5,7 @@ const getRecentGames = require('./getRecentGames');
|
|
|
5
5
|
module.exports = async function (query, options = { guild: false, recentGames: false }) {
|
|
6
6
|
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
7
7
|
const Player = require('../structures/Player');
|
|
8
|
-
query = await toUuid(query);
|
|
8
|
+
query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
|
|
9
9
|
const res = await this._makeRequest(`/player?uuid=${query}`);
|
|
10
10
|
if (res.raw) return res;
|
|
11
11
|
if (query && !res.player) throw new Error(Errors.PLAYER_HAS_NEVER_LOGGED);
|
|
@@ -5,7 +5,7 @@ module.exports = async function (query, playerData) {
|
|
|
5
5
|
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
6
6
|
const RecentGame = require('../structures/RecentGame');
|
|
7
7
|
|
|
8
|
-
query = await toUuid(query);
|
|
8
|
+
query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
|
|
9
9
|
|
|
10
10
|
const res = await this._makeRequest(`/recentgames?uuid=${query}`);
|
|
11
11
|
if (res.raw) return res;
|
package/src/API/getServerInfo.js
CHANGED
|
@@ -2,7 +2,9 @@ const net = require('net');
|
|
|
2
2
|
const Errors = require('../Errors');
|
|
3
3
|
const ServerInfo = require('../structures/ServerInfo');
|
|
4
4
|
const varInt = require('../utils/varInt');
|
|
5
|
-
const packetsToSend = ['1500E0050E6D632E6879706978656C2E6E657463DD01', '0100', '09010000000000000000'].map((x) =>
|
|
5
|
+
const packetsToSend = ['1500E0050E6D632E6879706978656C2E6E657463DD01', '0100', '09010000000000000000'].map((x) =>
|
|
6
|
+
Buffer.from(x, 'hex')
|
|
7
|
+
); // To avoid dependency hell, these are precompiled as hex.
|
|
6
8
|
module.exports = async function (repeats) {
|
|
7
9
|
if (repeats < 0 || typeof repeats !== 'number') repeats = 3;
|
|
8
10
|
if (repeats > 10) repeats = 10;
|
package/src/API/getStatus.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const toUuid = require('../utils/toUuid');
|
|
2
2
|
module.exports = async function (query) {
|
|
3
3
|
const Status = require('../structures/Status');
|
|
4
|
-
query = await toUuid(query);
|
|
4
|
+
query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
|
|
5
5
|
const res = await this._makeRequest(`/status?uuid=${query}`);
|
|
6
6
|
if (res.raw) return res;
|
|
7
7
|
return new Status(res.session);
|
package/src/API/index.js
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
getAchievements: require('./getAchievements.js'),
|
|
3
|
+
getAPIStatus: require('./getAPIStatus.js'),
|
|
4
|
+
getBoosters: require('./getBoosters.js'),
|
|
5
|
+
getChallenges: require('./getChallenges.js'),
|
|
6
|
+
getGameCounts: require('./getGameCounts.js'),
|
|
7
|
+
getGuild: require('./getGuild.js'),
|
|
8
|
+
getGuildAchievements: require('./getGuildAchievements.js'),
|
|
9
|
+
getLeaderboards: require('./getLeaderboards.js'),
|
|
10
|
+
getPlayer: require('./getPlayer.js'),
|
|
11
|
+
getQuests: require('./getQuests.js'),
|
|
12
|
+
getRecentGames: require('./getRecentGames.js'),
|
|
13
|
+
getServerInfo: require('./getServerInfo.js'),
|
|
14
|
+
getStatus: require('./getStatus.js'),
|
|
15
|
+
getWatchdogStats: require('./getWatchdogStats.js'),
|
|
16
|
+
|
|
17
|
+
getSkyblockAuction: require('./skyblock/getAuction.js'),
|
|
18
|
+
getSkyblockAuctions: require('./skyblock/getAuctions.js'),
|
|
19
|
+
getSkyblockAuctionsByPlayer: require('./skyblock/getAuctionsByPlayer.js'),
|
|
20
|
+
getSkyblockBazaar: require('./skyblock/getBazaar.js'),
|
|
21
|
+
getSkyblockBingo: require('./skyblock/getBingo.js'),
|
|
22
|
+
getSkyblockBingoByPlayer: require('./skyblock/getBingoByPlayer.js'),
|
|
23
|
+
getSkyblockEndedAuctions: require('./skyblock/getEndedAuctions.js'),
|
|
24
|
+
getSkyblockFireSales: require('./skyblock/getFireSales.js'),
|
|
25
|
+
getSkyblockGovernment: require('./skyblock/getGovernment.js'),
|
|
26
|
+
getSkyblockMember: require('./skyblock/getMember.js'),
|
|
27
|
+
getSkyblockMuseum: require('./skyblock/getMuseum.js'),
|
|
28
|
+
getSkyblockNews: require('./skyblock/getNews.js'),
|
|
29
|
+
getSkyblockProfiles: require('./skyblock/getProfiles.js')
|
|
19
30
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const Errors = require('../../Errors');
|
|
2
|
+
const toUuid = require('../../utils/toUuid');
|
|
3
|
+
module.exports = async function (type, query, includeItemBytes = false) {
|
|
4
|
+
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
5
|
+
const Auction = require('../../structures/SkyBlock/Auctions/Auction');
|
|
6
|
+
let filter = '';
|
|
7
|
+
if (type === 'PROFILE') {
|
|
8
|
+
filter = 'profile';
|
|
9
|
+
} else if (type === 'PLAYER') {
|
|
10
|
+
query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
|
|
11
|
+
filter = 'player';
|
|
12
|
+
} else if (type === 'AUCTION') {
|
|
13
|
+
filter = 'uuid';
|
|
14
|
+
} else throw new Error(Errors.BAD_AUCTION_FILTER);
|
|
15
|
+
const res = await this._makeRequest(`/skyblock/auction?${filter}=${query}`);
|
|
16
|
+
if (res.raw) return res;
|
|
17
|
+
|
|
18
|
+
return res.auctions.length ? res.auctions.map((a) => new Auction(a, includeItemBytes)) : [];
|
|
19
|
+
};
|
|
@@ -30,8 +30,12 @@ module.exports = async function (range, options = {}) {
|
|
|
30
30
|
if (range == null || 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)
|
|
34
|
-
|
|
33
|
+
if (parseInt(options.retries) !== options.retries || options.retries > 10 || options.retries < 0) {
|
|
34
|
+
throw new Error(Errors.INVALID_OPTION_VALUE);
|
|
35
|
+
}
|
|
36
|
+
if (parseInt(options.cooldown) !== options.cooldown || options.cooldown > 3000 || options.cooldown < 0) {
|
|
37
|
+
throw new Error(Errors.INVALID_OPTION_VALUE);
|
|
38
|
+
}
|
|
35
39
|
range = range.sort();
|
|
36
40
|
const result = { auctions: [] };
|
|
37
41
|
const fetches = [];
|
|
@@ -3,7 +3,7 @@ const toUuid = require('../../utils/toUuid');
|
|
|
3
3
|
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
|
-
query = await toUuid(query);
|
|
6
|
+
query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
|
|
7
7
|
const res = await this._makeRequest(`/skyblock/auction?player=${query}`);
|
|
8
8
|
if (res.raw) return res;
|
|
9
9
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const getBingo = require('./getBingo');
|
|
2
|
+
const toUuid = require('../../utils/toUuid');
|
|
3
|
+
const Errors = require('../../Errors');
|
|
4
|
+
module.exports = async function (query, { fetchBingoData = false }) {
|
|
5
|
+
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
6
|
+
const PlayerBingo = require('../../structures/SkyBlock/PlayerBingo');
|
|
7
|
+
query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
|
|
8
|
+
const res = await this._makeRequest(`/skyblock/uuid?player=${query}`);
|
|
9
|
+
if (res.raw) return res;
|
|
10
|
+
let bingoData = null;
|
|
11
|
+
if (fetchBingoData) bingoData = await getBingo.call(this);
|
|
12
|
+
|
|
13
|
+
return new PlayerBingo(data, bingoData);
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
module.exports = async function () {
|
|
2
|
+
const FireSale = require('../../structures/SkyBlock/Static/FireSale');
|
|
3
|
+
const res = await this._makeRequest('/skyblock/firesales');
|
|
4
|
+
if (res.raw) return res;
|
|
5
|
+
|
|
6
|
+
return res.sales.length ? res.sales.map((a) => new FireSale(a)) : [];
|
|
7
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
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 }) {
|
|
4
|
+
module.exports = async function (query, options = { fetchPlayer: false, getMuseum: false }) {
|
|
5
5
|
const SkyblockMember = require('../../structures/SkyBlock/SkyblockMember');
|
|
6
|
+
const getSkyblockMuseum = require('../skyblock/getMuseum');
|
|
6
7
|
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
7
|
-
query = await toUuid(query);
|
|
8
|
+
query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
|
|
8
9
|
const res = await this._makeRequest(`/skyblock/profiles?uuid=${query}`);
|
|
9
10
|
if (res.raw) return res;
|
|
10
11
|
if (!res.profiles || !res.profiles.length) throw new Error(Errors.NO_SKYBLOCK_PROFILES);
|
|
@@ -16,9 +17,14 @@ module.exports = async function (query, options = { fetchPlayer: false }) {
|
|
|
16
17
|
profile.cute_name,
|
|
17
18
|
new SkyblockMember({
|
|
18
19
|
uuid: query,
|
|
20
|
+
profileId: profile.profile_id,
|
|
19
21
|
profileName: profile.cute_name,
|
|
20
22
|
gameMode: profile.game_mode || null,
|
|
21
|
-
m: profile.members[query]
|
|
23
|
+
m: profile.members[query],
|
|
24
|
+
banking: profile.banking,
|
|
25
|
+
communityUpgrades: profile.community_upgrades,
|
|
26
|
+
museum: options.getMuseum ? await getSkyblockMuseum.call(this, query, profile.profile_id) : null,
|
|
27
|
+
selected: profile.selected
|
|
22
28
|
})
|
|
23
29
|
);
|
|
24
30
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const Errors = require('../../Errors');
|
|
2
|
+
const toUuid = require('../../utils/toUuid');
|
|
3
|
+
module.exports = async function (query, profileId) {
|
|
4
|
+
const SkyblockMuseum = require('../../structures/SkyBlock/SkyblockMuseum');
|
|
5
|
+
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
6
|
+
query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
|
|
7
|
+
const res = await this._makeRequest(`/skyblock/museum?uuid=${query}&profile=${profileId}`);
|
|
8
|
+
if (res.raw) return res;
|
|
9
|
+
return new SkyblockMuseum({
|
|
10
|
+
uuid: query,
|
|
11
|
+
m: res,
|
|
12
|
+
profileId: profileId
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
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 }) {
|
|
4
|
+
module.exports = async function (query, options = { fetchPlayer: false, getMuseum: false }) {
|
|
5
5
|
const SkyblockProfile = require('../../structures/SkyBlock/SkyblockProfile');
|
|
6
|
+
const getSkyblockMuseum = require('../skyblock/getMuseum');
|
|
6
7
|
if (!query) throw new Error(Errors.NO_NICKNAME_UUID);
|
|
7
|
-
query = await toUuid(query);
|
|
8
|
+
query = await toUuid(query, this.options.mojangCacheTime, this.options.useThirdPartyAPI);
|
|
8
9
|
const res = await this._makeRequest(`/skyblock/profiles?uuid=${query}`);
|
|
9
10
|
if (res.raw) return res;
|
|
10
11
|
if (!res.profiles || !res.profiles.length) throw new Error(Errors.NO_SKYBLOCK_PROFILES);
|
|
@@ -28,11 +29,16 @@ module.exports = async function (query, options = { fetchPlayer: false }) {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
profiles.push({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
uuid: query,
|
|
33
|
+
profileId: res.profiles[i].profile_id,
|
|
34
|
+
profileName: res.profiles[i].cute_name,
|
|
35
|
+
gameMode: res.profiles[i].game_mode || null,
|
|
36
|
+
m: res.profiles[i].members[query],
|
|
37
|
+
banking: res.profiles[i].banking,
|
|
38
|
+
communityUpgrades: res.profiles[i].community_upgrades,
|
|
39
|
+
museum: options.getMuseum ? await getSkyblockMuseum.call(this, query, res.profiles[i].profile_id) : null,
|
|
40
|
+
selected: res.profiles[i].selected,
|
|
41
|
+
members: res.profiles[i].members
|
|
36
42
|
});
|
|
37
43
|
}
|
|
38
44
|
|
package/src/Client.js
CHANGED
|
@@ -13,7 +13,7 @@ const clients = [];
|
|
|
13
13
|
*/
|
|
14
14
|
class Client extends EventEmitter {
|
|
15
15
|
/**
|
|
16
|
-
* @param {string} key API key
|
|
16
|
+
* @param {string} key API key
|
|
17
17
|
* @param {ClientOptions} [options={}] Client options
|
|
18
18
|
*/
|
|
19
19
|
constructor(key, options = {}) {
|
|
@@ -32,11 +32,11 @@ class Client extends EventEmitter {
|
|
|
32
32
|
validate.validateOptions(this.options);
|
|
33
33
|
// eslint-disable-next-line guard-for-in
|
|
34
34
|
for (const func in API) {
|
|
35
|
-
Client.prototype[func] =
|
|
35
|
+
Client.prototype[func] = (...args) => {
|
|
36
36
|
const lastArg = args[args.length - 1];
|
|
37
37
|
return API[func].apply(
|
|
38
38
|
{
|
|
39
|
-
_makeRequest: this._makeRequest.bind(this,
|
|
39
|
+
_makeRequest: this._makeRequest.bind(this, validate.cacheSuboptions(lastArg) ? lastArg : {}),
|
|
40
40
|
...this
|
|
41
41
|
},
|
|
42
42
|
args
|
|
@@ -45,7 +45,10 @@ class Client extends EventEmitter {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
if (this.options.checkForUpdates) {
|
|
48
|
-
updater.checkForUpdates()
|
|
48
|
+
updater.checkForUpdates().catch(() => {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
if (!this.options.silent) console.warn('[hypixel-api-reborn] Error whilst checking for updates!');
|
|
51
|
+
});
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
54
|
* All cache entries
|
|
@@ -53,7 +56,7 @@ class Client extends EventEmitter {
|
|
|
53
56
|
*/
|
|
54
57
|
this.cache = this.requests.cache;
|
|
55
58
|
clients.push(this);
|
|
56
|
-
rateLimit.init(this.
|
|
59
|
+
rateLimit.init(this.getGameCounts(), this.options, this).then(() => this.emit('ready'));
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
59
62
|
* Private function - make request
|
|
@@ -65,10 +68,15 @@ class Client extends EventEmitter {
|
|
|
65
68
|
*/
|
|
66
69
|
async _makeRequest(options, url, useRateLimitManager = true) {
|
|
67
70
|
if (!url) return;
|
|
68
|
-
if (url !== '/key' && !options.noCacheCheck && (await this.requests.cache.has(url)))
|
|
71
|
+
if (url !== '/key' && !options.noCacheCheck && (await this.requests.cache.has(url))) {
|
|
72
|
+
return Object.assign(await this.requests.cache.get(url), { raw: !!options.raw });
|
|
73
|
+
}
|
|
69
74
|
if (useRateLimitManager) await rateLimit.rateLimitManager();
|
|
70
75
|
this.emit('outgoingRequest', url, { ...options, headers: { ...options.headers, ...this.options.headers } });
|
|
71
|
-
const result = await this.requests.request.call(this.requests, url, {
|
|
76
|
+
const result = await this.requests.request.call(this.requests, url, {
|
|
77
|
+
...options,
|
|
78
|
+
headers: { ...options.headers, ...this.options.headers }
|
|
79
|
+
});
|
|
72
80
|
if (this.options.syncWithHeaders) rateLimit.sync(result._headers);
|
|
73
81
|
return result;
|
|
74
82
|
}
|
|
@@ -143,6 +151,11 @@ class Client extends EventEmitter {
|
|
|
143
151
|
* }).catch(e => {
|
|
144
152
|
* console.log(e);
|
|
145
153
|
* })
|
|
154
|
+
* @example
|
|
155
|
+
* // async/await
|
|
156
|
+
* const guild = await hypixel.getGuild('name', 'The Foundation').catch(console.log);
|
|
157
|
+
* console.log(guild.level); // 111
|
|
158
|
+
* console.log(guild.id); // '52e5719284ae51ed0c716c69'
|
|
146
159
|
*/
|
|
147
160
|
/**
|
|
148
161
|
* Allows you to get statistics of watchdog, the server anticheat
|
|
@@ -156,6 +169,10 @@ class Client extends EventEmitter {
|
|
|
156
169
|
* }).catch(e => {
|
|
157
170
|
* console.log(e);
|
|
158
171
|
* })
|
|
172
|
+
* @example
|
|
173
|
+
* // async/await
|
|
174
|
+
* const watchdog = await hypixel.getWatchdogStats().catch(console.log);
|
|
175
|
+
* console.log(watchdog.byWatchdogTotal); // 5931897
|
|
159
176
|
*/
|
|
160
177
|
/**
|
|
161
178
|
* Allows you to get all active boosters
|
|
@@ -169,6 +186,10 @@ class Client extends EventEmitter {
|
|
|
169
186
|
* }).catch(e => {
|
|
170
187
|
* console.log(e);
|
|
171
188
|
* })
|
|
189
|
+
* @example
|
|
190
|
+
* // async/await
|
|
191
|
+
* const boosters = await hypixel.getBoosters().catch(console.log);
|
|
192
|
+
* console.log(boosters[0].purchaser); // '978ddb705a8e43618e41749178c020b0'
|
|
172
193
|
*/
|
|
173
194
|
/**
|
|
174
195
|
* Allows you to get all skyblock profiles of player
|
|
@@ -183,13 +204,16 @@ class Client extends EventEmitter {
|
|
|
183
204
|
* }).catch(e => {
|
|
184
205
|
* console.log(e);
|
|
185
206
|
* })
|
|
207
|
+
* @example
|
|
208
|
+
* const profiles = await hypixel.getSkyblockProfiles('StavZDev').catch(console.log);
|
|
209
|
+
* console.log(profiles[0].members[0].uuid); // '52d9a36f66ce4cdf9a56ad9724ae9fb4'
|
|
186
210
|
*/
|
|
187
211
|
/**
|
|
188
212
|
* Allows you to get a player's skyblock member data from all their profiles
|
|
189
213
|
* @method
|
|
190
214
|
* @name Client#getSkyblockMember
|
|
191
215
|
* @param {string} query Player nickname or UUID
|
|
192
|
-
* @param {
|
|
216
|
+
* @param {SkyblockMethodOptions} [options={}] Method options
|
|
193
217
|
* @return {Promise<Map<string,SkyblockMember>>}
|
|
194
218
|
* @example
|
|
195
219
|
* hypixel.getSkyblockMember('StavZDev').then(member => {
|
|
@@ -198,6 +222,17 @@ class Client extends EventEmitter {
|
|
|
198
222
|
* }).catch(e => {
|
|
199
223
|
* console.log(e);
|
|
200
224
|
* })
|
|
225
|
+
* @example
|
|
226
|
+
* const member = await hypixel.getSkyblockMember('StavZDev').catch(console.log);
|
|
227
|
+
* console.log(member.get('Cucumber').uuid); // '52d9a36f66ce4cdf9a56ad9724ae9fb4'
|
|
228
|
+
*/
|
|
229
|
+
/**
|
|
230
|
+
* Allows you to get a player's skyblock profile museum
|
|
231
|
+
* @method
|
|
232
|
+
* @name Client#getSkyblockMuseum
|
|
233
|
+
* @param {string} query Player nickname or UUID
|
|
234
|
+
* @param {string} profileId Profile ID
|
|
235
|
+
* @return {Promise<SkyblockMuseum>}
|
|
201
236
|
*/
|
|
202
237
|
/**
|
|
203
238
|
* Allows you to get the Hypixel API's Status and past Incidents, no key needed.
|
|
@@ -312,6 +347,34 @@ class Client extends EventEmitter {
|
|
|
312
347
|
* console.log(products[0].productId); // INK_SACK:3
|
|
313
348
|
* })
|
|
314
349
|
* .catch(console.log);
|
|
350
|
+
*/ /**
|
|
351
|
+
* Allows you to get bingo data
|
|
352
|
+
* @method
|
|
353
|
+
* @name Client#getSkyblockBingo
|
|
354
|
+
* @param {MethodOptions} [options={}] Options
|
|
355
|
+
* @return {Promise<BingoData>}
|
|
356
|
+
*/
|
|
357
|
+
/**
|
|
358
|
+
* Allows you to get bingo data of a player
|
|
359
|
+
* @method
|
|
360
|
+
* @name Client#getSkyblockBingoByPlayer
|
|
361
|
+
* @param {string} query UUID / IGN of player
|
|
362
|
+
* @param {PlayerBingoOptions} [options={}] Options
|
|
363
|
+
* @return {Promise<PlayerBingo>}
|
|
364
|
+
*/
|
|
365
|
+
/**
|
|
366
|
+
* Allows you to get SB government
|
|
367
|
+
* @method
|
|
368
|
+
* @name Client#getSkyblockGovernment
|
|
369
|
+
* @param {MethodOptions} [options={}] Options
|
|
370
|
+
* @return {Promise<GovernmentData>}
|
|
371
|
+
*/
|
|
372
|
+
/**
|
|
373
|
+
* Allows you to get SB government
|
|
374
|
+
* @method
|
|
375
|
+
* @name Client#getSkyblockFireSale
|
|
376
|
+
* @param {MethodOptions} [options={}] Options
|
|
377
|
+
* @return {Promise<FireSale[]>}
|
|
315
378
|
*/
|
|
316
379
|
/**
|
|
317
380
|
* Allows you to get skyblock news
|
|
@@ -348,16 +411,18 @@ class Client extends EventEmitter {
|
|
|
348
411
|
}
|
|
349
412
|
/**
|
|
350
413
|
* @typedef {object} ClientOptions
|
|
351
|
-
* @prop {boolean} [cache=
|
|
352
|
-
* @prop {number} [
|
|
414
|
+
* @prop {boolean} [cache=true] Enable/Disable request caching.
|
|
415
|
+
* @prop {number} [hypixelCacheTime=60] Amount of time in seconds to cache the hypixel api requests.
|
|
416
|
+
* @prop {number} [mojangCacheTime=600] Amount of time in seconds to cache the mojang api requests.
|
|
353
417
|
* @prop {CacheHandler} [cacheHandler] Custom Cache Handler
|
|
354
418
|
* @prop {AUTO|HARD|NONE} [rateLimit='AUTO'] Rate limit mode.
|
|
355
419
|
* @prop {boolean} [syncWithHeaders=false] Sync with headers rate limit information. Usually not necessary nor recommended ( because of latency )
|
|
356
|
-
* @prop {number} [keyLimit=
|
|
420
|
+
* @prop {number} [keyLimit=60] Key limit of your key.
|
|
357
421
|
* @prop {number} [cacheSize=-1] The amount how many results will be cached. (`-1` for infinity)
|
|
358
422
|
* @prop {boolean} [silent=false] Don't automatically put warnings into console.
|
|
359
423
|
* @prop {object} [headers={}] Extra Headers ( like User-Agent ) to add to request.
|
|
360
424
|
* @prop {boolean} [checkForUpdates=true] Enable/Disable check for new version of hypixel-api-reborn.
|
|
425
|
+
* @prop {boolean|string} [useThirdPartyAPI=false] Enable/Disable Mojang Third Party API
|
|
361
426
|
*/
|
|
362
427
|
const defaultCache = require('./Private/defaultCache.js');
|
|
363
428
|
/**
|
|
@@ -384,9 +449,10 @@ const defaultCache = require('./Private/defaultCache.js');
|
|
|
384
449
|
*/
|
|
385
450
|
/**
|
|
386
451
|
* @typedef {object} SkyblockMethodOptions
|
|
387
|
-
* @property {boolean} [
|
|
388
|
-
* @property {
|
|
389
|
-
* @property {
|
|
452
|
+
* @property {boolean} [fetchPlayer=false] Raw data
|
|
453
|
+
* @property {boolean} [getMuseum=false] Raw data
|
|
454
|
+
* @property {boolean} [noCacheCheck=false] Disable/Enable cache checking
|
|
455
|
+
* @property {boolean} [noCaching=false] Disable/Enable writing to cache
|
|
390
456
|
* @property {?boolean} [fetchPlayer=false] Disable/Enable player profile request for each member
|
|
391
457
|
* @prop {object} [headers={}] Extra Headers ( like User-Agent ) to add to request. Overrides the headers globally provided.
|
|
392
458
|
*/
|
|
@@ -403,4 +469,12 @@ const defaultCache = require('./Private/defaultCache.js');
|
|
|
403
469
|
* @property {boolean} [includeItemBytes=false] Whether to include item bytes in the result
|
|
404
470
|
* @prop {object} [headers={}] Extra Headers ( like User-Agent ) to add to request. Overrides the headers globally provided.
|
|
405
471
|
*/
|
|
472
|
+
/**
|
|
473
|
+
* @typedef {object} PlayerBingoOptions
|
|
474
|
+
* @property {boolean} [raw=false] Raw data
|
|
475
|
+
* @property {boolean} [noCacheCheck=false] Disable/Enable cache checking
|
|
476
|
+
* @property {boolean} [noCaching=false] Disable/Enable writing to cache
|
|
477
|
+
* @property {boolean} [fetchBingoData=false] Fetches bingo data to give more information
|
|
478
|
+
* @prop {object} [headers={}] Extra Headers ( like User-Agent ) to add to request. Overrides the headers globally provided.
|
|
479
|
+
*/
|
|
406
480
|
module.exports = Client;
|