From e3f7e79c0b61721d783fdc293f8c71c675d6bc93 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 14 Aug 2024 12:54:55 +0800 Subject: [PATCH] Importing --- src/API/API.d.ts | 4 +- src/API/getPlayer.ts | 4 +- src/API/getSkyblockAuctions.ts | 8 +-- src/API/getSkyblockEndedAuctions.ts | 24 ------- src/API/getSkyblockMember.ts | 6 +- src/API/getSkyblockProfiles.ts | 4 +- src/API/getWatchdogStats.ts | 2 +- src/API/index.ts | 6 +- src/Client.ts | 3 - src/index.ts | 3 +- src/structures/SkyBlock/SkyblockMember.ts | 6 ++ src/typings/index.d.ts | 81 +++++++++++++++++++---- 12 files changed, 96 insertions(+), 55 deletions(-) delete mode 100644 src/API/getSkyblockEndedAuctions.ts diff --git a/src/API/API.d.ts b/src/API/API.d.ts index 7d6002f5..1163863f 100644 --- a/src/API/API.d.ts +++ b/src/API/API.d.ts @@ -1,6 +1,6 @@ import { RequestOptions } from '../Private/Requests'; -export interface getPlayerRequestOptions extends RequestOptions { +export interface PlayerRequestOptions extends RequestOptions { getGuild?: boolean; } @@ -8,7 +8,7 @@ export interface AuctionRequestOptions extends RequestOptions { includeItemBytes?: boolean; } -export interface SkyblockRequestyOptions extends RequestOptions { +export interface SkyblockRequestOptions extends RequestOptions { garden?: boolean; museum?: boolean; } diff --git a/src/API/getPlayer.ts b/src/API/getPlayer.ts index a2c1c911..ac2fd616 100644 --- a/src/API/getPlayer.ts +++ b/src/API/getPlayer.ts @@ -1,4 +1,4 @@ -import { getPlayerRequestOptions } from './API'; +import { PlayerRequestOptions } from './API'; import Endpoint from '../Private/Endpoint'; import Player from '../structures/Player'; import Client from '../Client'; @@ -10,7 +10,7 @@ export default class getPlayer extends Endpoint { this.client = client; } - async execute(query: string, options?: getPlayerRequestOptions): Promise { + async execute(query: string, options?: PlayerRequestOptions): Promise { if (!query) throw new Error(this.client.errors.NO_NICKNAME_UUID); query = await this.client.requests.toUUID(query); const res = await this.client.requests.request(`/player?uuid=${query}`, options); diff --git a/src/API/getSkyblockAuctions.ts b/src/API/getSkyblockAuctions.ts index b5927b9f..5b83fc46 100644 --- a/src/API/getSkyblockAuctions.ts +++ b/src/API/getSkyblockAuctions.ts @@ -19,7 +19,10 @@ export default class getSkyblockAuctions extends Endpoint { this.client = client; } - async execute(range: any, options?: getSkyblockAuctionsOptions) { + async execute( + range: any, + options?: getSkyblockAuctionsOptions + ): Promise<{ info: AuctionInfo | null; auctions: Auction[] }> { options = this.parasOptions(options); options.retries ||= 3; options.cooldown ||= 100; @@ -36,9 +39,6 @@ export default class getSkyblockAuctions extends Endpoint { const result: any = { auctions: [] }; const fetches = []; const failedPages = []; - if (options.noAuctions) { - return { info: options.noInfo ? null : (await this.getPage(range[1], { noAuctions: true })).info }; - } for (let i = range[0]; i <= range[1]; i++) { if (options.race) { fetches.push(this.noReject(this.getPage, [i, options], options.retries, options.cooldown)); diff --git a/src/API/getSkyblockEndedAuctions.ts b/src/API/getSkyblockEndedAuctions.ts deleted file mode 100644 index 4f05e278..00000000 --- a/src/API/getSkyblockEndedAuctions.ts +++ /dev/null @@ -1,24 +0,0 @@ -import PartialAuction from '../structures/SkyBlock/Auctions/PartialAuction'; -import AuctionInfo from '../structures/SkyBlock/Auctions/AuctionInfo'; -import { AuctionRequestOptions } from './API'; -import Endpoint from '../Private/Endpoint'; -import Client from '../Client'; - -export default class getSkyblockEndedAuctions extends Endpoint { - readonly client: Client; - constructor(client: Client) { - super(client); - this.client = client; - } - - async execute(options?: AuctionRequestOptions): Promise<{ info: AuctionInfo; auctions: PartialAuction[] }> { - const res = await this.client.requests.request('/skyblock/auctions_ended', options); - if (res.raw) return res; - return { - info: new AuctionInfo({ ...res, totalAuctions: res.auctions.length, totalPages: 1 }), - auctions: res.auctions.length - ? res.auctions.map((a: any) => new PartialAuction(a, options?.includeItemBytes ?? false)) - : [] - }; - } -} diff --git a/src/API/getSkyblockMember.ts b/src/API/getSkyblockMember.ts index 7f270dd0..cef352a5 100644 --- a/src/API/getSkyblockMember.ts +++ b/src/API/getSkyblockMember.ts @@ -1,5 +1,5 @@ import SkyblockMember from '../structures/SkyBlock/SkyblockMember'; -import { SkyblockRequestyOptions } from './API'; +import { SkyblockRequestOptions } from './API'; import Endpoint from '../Private/Endpoint'; import Client from '../Client'; @@ -10,7 +10,7 @@ export default class getSkyblockMember extends Endpoint { this.client = client; } - async execute(query: string, options?: SkyblockRequestyOptions): Promise> { + async execute(query: string, options?: SkyblockRequestOptions): Promise> { if (!query) throw new Error(this.client.errors.NO_NICKNAME_UUID); query = await this.client.requests.toUUID(query); const res = await this.client.requests.request(`/skyblock/profiles?uuid=${query}`, options); @@ -23,6 +23,8 @@ export default class getSkyblockMember extends Endpoint { new SkyblockMember({ uuid: query, profileId: profile.profile_id, + garden: options?.garden ? await this.client.getSkyblockGarden(profile.profile_id) : null, + museum: options?.garden ? await this.client.getSkyblockMuseum(query, profile.profile_id) : null, profileName: profile.cute_name, gameMode: profile.game_mode || null, m: profile.members[query], diff --git a/src/API/getSkyblockProfiles.ts b/src/API/getSkyblockProfiles.ts index 1cb320db..6bea087a 100644 --- a/src/API/getSkyblockProfiles.ts +++ b/src/API/getSkyblockProfiles.ts @@ -1,5 +1,5 @@ import SkyblockProfile from '../structures/SkyBlock/SkyblockProfile'; -import { SkyblockRequestyOptions } from './API'; +import { SkyblockRequestOptions } from './API'; import Endpoint from '../Private/Endpoint'; import Client from '../Client'; export default class getSkyblockProfiles extends Endpoint { @@ -9,7 +9,7 @@ export default class getSkyblockProfiles extends Endpoint { this.client = client; } - async execute(query: string, options?: SkyblockRequestyOptions): Promise { + async execute(query: string, options?: SkyblockRequestOptions): Promise { if (!query) throw new Error(this.client.errors.NO_NICKNAME_UUID); query = await this.client.requests.toUUID(query); const res = await this.client.requests.request(`/skyblock/profiles?uuid=${query}`, options); diff --git a/src/API/getWatchdogStats.ts b/src/API/getWatchdogStats.ts index 9bce4668..8dfef5de 100644 --- a/src/API/getWatchdogStats.ts +++ b/src/API/getWatchdogStats.ts @@ -3,7 +3,7 @@ import { RequestOptions } from '../Private/Requests'; import Endpoint from '../Private/Endpoint'; import Client from '../Client'; -export default class getWatchdogStatsEndpoint extends Endpoint { +export default class getWatchdogStats extends Endpoint { readonly client: Client; constructor(client: Client) { super(client); diff --git a/src/API/index.ts b/src/API/index.ts index d052e832..fea0d75f 100644 --- a/src/API/index.ts +++ b/src/API/index.ts @@ -12,15 +12,16 @@ import getPlayerHouses from './getPlayerHouses'; import getQuests from './getQuests'; import getRecentGames from './getRecentGames'; import getSkyblockAuction from './getSkyblockAuction'; +import getSkyblockAuctions from './getSkyblockAuctions'; import getSkyblockAuctionsByPlayer from './getSkyblockAuctionsByPlayer'; import getSkyblockBazaar from './getSkyblockBazaar'; import getSkyblockBingo from './getSkyblockBingo'; import getSkyblockBingoByPlayer from './getSkyblockBingoByPlayer'; -import getSkyblockEndedAuctions from './getSkyblockEndedAuctions'; import getSkyblockFireSales from './getSkyblockFireSales'; import getSkyblockGarden from './getSkyblockGarden'; import getSkyblockGovernment from './getSkyblockGovernment'; import getSkyblockMember from './getSkyblockMember'; +import getSkyblockMuseum from './getSkyblockMuseum'; import getSkyblockNews from './getSkyblockNews'; import getSkyblockProfiles from './getSkyblockProfiles'; import getStatus from './getStatus'; @@ -41,15 +42,16 @@ export default { getQuests, getRecentGames, getSkyblockAuction, + getSkyblockAuctions, getSkyblockAuctionsByPlayer, getSkyblockBazaar, getSkyblockBingo, getSkyblockBingoByPlayer, - getSkyblockEndedAuctions, getSkyblockFireSales, getSkyblockGarden, getSkyblockGovernment, getSkyblockMember, + getSkyblockMuseum, getSkyblockNews, getSkyblockProfiles, getStatus, diff --git a/src/Client.ts b/src/Client.ts index 0d3bd82c..f6309106 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -8,9 +8,6 @@ import API from './API'; const clients: Client[] = []; class Client { - getGuild(...args: any[]): Promise | any { - throw new Error('Method not implemented.'); - } readonly key: string; declare requests: Requests; diff --git a/src/index.ts b/src/index.ts index 71cf5124..d6e3da9d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,15 +21,16 @@ export * from './API/getPlayerHouses'; export * from './API/getQuests'; export * from './API/getRecentGames'; export * from './API/getSkyblockAuction'; +export * from './API/getSkyblockAuctions'; export * from './API/getSkyblockAuctionsByPlayer'; export * from './API/getSkyblockBazaar'; export * from './API/getSkyblockBingo'; export * from './API/getSkyblockBingoByPlayer'; -export * from './API/getSkyblockEndedAuctions'; export * from './API/getSkyblockFireSales'; export * from './API/getSkyblockGarden'; export * from './API/getSkyblockGovernment'; export * from './API/getSkyblockMember'; +export * from './API/getSkyblockMuseum'; export * from './API/getSkyblockNews'; export * from './API/getSkyblockProfiles'; export * from './API/getStatus'; diff --git a/src/structures/SkyBlock/SkyblockMember.ts b/src/structures/SkyBlock/SkyblockMember.ts index c3cb952d..860d024d 100644 --- a/src/structures/SkyBlock/SkyblockMember.ts +++ b/src/structures/SkyBlock/SkyblockMember.ts @@ -23,6 +23,8 @@ import { getNetworth, NetworthResult } from 'skyhelper-networth'; import SkyblockInventoryItem from './SkyblockInventoryItem'; import Constants from '../../utils/Constants'; import SkyblockPet from './SkyblockPet'; +import SkyblockGarden from './SkyblockGarden'; +import SkyblockMuseum from './SkyblockMuseum'; export interface SkyblockMemberEquipment { gauntlet: SkyblockInventoryItem | null; @@ -45,6 +47,8 @@ class SkyblockMember { uuid: string; gameMode: string | null; selected: boolean; + garden: SkyblockGarden | null; + museum: SkyblockMuseum | null; profileName: string; profileId: string; firstJoinTimestamp: number; @@ -79,6 +83,8 @@ class SkyblockMember { this.uuid = data.uuid; this.gameMode = data.gameMode; this.selected = data.selected; + this.garden = data.garden; + this.museum = data.museum; this.profileName = data.profileName; this.profileId = data.profileId; this.firstJoinTimestamp = data.m.profile?.first_join; diff --git a/src/typings/index.d.ts b/src/typings/index.d.ts index afe9e1e7..d6c53754 100644 --- a/src/typings/index.d.ts +++ b/src/typings/index.d.ts @@ -1,6 +1,34 @@ +import Requests, { RequestOptions } from '../Private/Requests'; import CacheHandler from '../Private/CacheHandler'; -import Requests from '../Private/Requests'; import { ClientOptions } from '../Client'; +import Updater from '../Private/Updater'; +import Errors from '../Errors'; +import Achievements from '../structures/Static/Achievements'; +import House from '../structures/House'; +import Booster from '../structures/Boosters/Booster'; +import Challenges from '../structures/Static/Challenges'; +import GameCounts from '../structures/GameCounts'; +import Guild from '../structures/Guild/Guild'; +import GuildAchievements from '../structures/Static/GuildAchievements'; +import Player from '../structures/Player'; +import Quests from '../structures/Static/Quests'; +import RecentGame from '../structures/RecentGame'; +import { AuctionRequestOptions, SkyblockRequestOptions } from '../API/API'; +import Auction from '../structures/SkyBlock/Auctions/Auction'; +import { getSkyblockAuctionsOptions } from '../API/getSkyblockAuctions'; +import AuctionInfo from '../structures/SkyBlock/Auctions/AuctionInfo'; +import Product from '../structures/SkyBlock/Bazzar/Product'; +import BingoData from '../structures/SkyBlock/Static/BingoData'; +import PlayerBingo from '../structures/SkyBlock/PlayerBingo'; +import FireSale from '../structures/SkyBlock/Static/FireSale'; +import SkyblockGarden from '../structures/SkyBlock/SkyblockGarden'; +import GovernmentData from '../structures/SkyBlock/Static/Government'; +import SkyblockMember from '../structures/SkyBlock/SkyblockMember'; +import SkyblockMuseum from '../structures/SkyBlock/SkyblockMuseum'; +import SkyblockNews from '../structures/SkyBlock/News/SkyblockNews'; +import SkyblockProfile from '../structures/SkyBlock/SkyblockProfile'; +import Status from '../structures/Status'; +import WatchdogStats from '../structures/Watchdog/Stats'; export type StaticGameNames = | 'arcade' @@ -27,24 +55,53 @@ export type StaticGameNames = | 'battleground' | 'woolgames'; -declare module 'reborn-ts' { - const version: string; - +declare module 'hypixel-api-reborn' { class Client { readonly key: string; declare requests: Requests; declare cacheHandler: CacheHandler; + declare updater: Updater; + declare errors: Errors; - declare cache: boolean; - declare cacheTime: number; - declare cacheMaxKeys: number; - declare cacheCheckPeriod: number; - declare rateLimit?: 'AUTO' | 'HARD' | 'NONE'; - declare silent: boolean; - declare checkForUpdates: boolean; - declare endpoints: any; + declare options: ClientOptions; constructor(key: string, options?: ClientOptions); + + getAchievements(options?: RequestOptions): Promise; + getActiveHouses(options?: RequestOptions): Promise; + getBoosters(options?: RequestOptions): Promise; + getChallenges(options?: RequestOptions): Promise; + getGameCounts(options?: RequestOptions): Promise; + getGuild(searchParameter: 'id' | 'name' | 'player', query: string, options?: RequestOptions): Promise; + getGuildAchievements(options?: RequestOptions): Promise; + getHouse(query: string, options?: RequestOptions): Promise; + getLeaderboards(options?: RequestOptions): Promise; + getPlayer(query: string, options?: PlayerRequestOptions): Promise; + getPlayerHouses(query: string, options?: RequestOptions): Promise; + getQuests(options?: RequestOptions): Promise; + getRecentGames(query: string, options?: RequestOptions): Promise; + getSkyblockAuction( + query: string, + type: 'PROFILE' | 'PLAYER' | 'AUCTION', + options?: AuctionRequestOptions + ): Promise; + getSkyblockAuctions( + range: any, + options?: getSkyblockAuctionsOptions + ): Promise<{ info: AuctionInfo | null; auctions: Auction[] }>; + getSkyblockAuctionsByPlayer(query: string, options?: AuctionRequestOptions): Promise; + getSkyblockBazaar(options?: RequestOptions): Promise; + getSkyblockBingo(options?: RequestOptions): Promise; + getSkyblockBingoByPlayer(query: string, options?: RequestOptions): Promise; + getSkyblockFireSales(options?: RequestOptions): Promise; + getSkyblockGarden(profileId: string, options?: RequestOptions): Promise; + getSkyblockGovernment(options?: RequestOptions): Promise; + getSkyblockMember(query: string, options?: SkyblockRequestOptions): Promise>; + getSkyblockMuseum(query: string, profileId: string, options?: RequestOptions): Promise; + getSkyblockNews(options?: RequestOptions): Promise; + getSkyblockProfiles(query: string, options?: SkyblockRequestOptions): Promise; + getStatus(query: string, options?: RequestOptions): Promise; + getWatchdogStats(options?: RequestOptions): Promise; } }