diff --git a/README.md b/README.md index 62ba075..2b7975f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@
![banner](https://raw.githubusercontent.com/hypixelts/assets/main/svg/full-nobg5232x945.svg) - +## Fixed version ## **An easy to use [Hypixel API](https://api.hypixel.net) wrapper.**

diff --git a/dist/cjs/index.d.ts b/dist/cjs/index.d.ts new file mode 100644 index 0000000..736b8f0 --- /dev/null +++ b/dist/cjs/index.d.ts @@ -0,0 +1,1285 @@ +export { HypixelAPIError, HypixelAPIErrorResponse } from './lib/rest/HypixelAPIError.js'; + +/** + * The base manager which all other managers extend from + * @category Managers + * @group Managers + */ +declare class BaseManager { + /** + * Whether or not the manager requires API key authorization. + */ + protected requiresAuth: boolean; + /** + * The instantiated hypixel.ts client + */ + protected client: Client; + constructor(client: Client, requiresAuth: boolean); + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + protected makeGetRequest(path: string): Promise; +} + +/** + * The base class which all other classes extend from. + * @category Classes + * @group Classes + */ +declare class Base { + /** + * The instantiated hypixel.ts client. + */ + protected client: Client; + constructor(client: Client); +} + +/** + * The Guild object returned from the API (in JSON) which is converted to @see {@link Guild} class. + * @category Interfaces + */ +interface APIGuild { + _id: string; + id: string; + name: string; + nameLower: string; + coins: number; + coinsEver: number; + created: number; + members: APIGuildMember[]; + ranks: APIGuildRank[]; + achievements: Record; + exp: number; + guildExpByGameType: Record; +} + +/** + * @category Interfaces + */ +interface APIGuildMember { + uuid: string; + rank: string; + joined: number; + questParticipation: number; + expHistory: Record; +} + +/** + * @category Interfaces + */ +interface APIGuildRank { + name: string; + priority: number; + created: number; + default?: boolean; +} + +/** + * The Player object returned from the API (in JSON) which is converted to the @see {@link Player} class. + * @category Interfaces + */ +interface APIPlayer { + /** + * The uuid of the player. + */ + uuid: string; + + /** + * The display name of the player. + */ + displayName: string | null; + + /** + * The rank of the player + */ + rank: 'ADMIN' | 'MODERATOR' | 'HELPER' | 'NORMAL' | null; + + /** + * The package rank of the player + */ + packageRank: 'MVP_PLUS' | 'MVP' | 'VIP_PLUS' | 'VIP' | 'NONE' | null; + + /** + * The monthly package rank of the player + */ + monthlyPackageRank: 'SUPERSTAR' | 'NONE' | null; + + /** + * First login time of player (in milliseconds) + */ + firstLogin: number | null; + + /** + * Last login time of player (in milliseconds) + */ + lastLogin: number | null; + + /** + * Last logout time of player (in milliseconds) + */ + lastLogout: number | null; + + /** + * Undocumented fields (observed in API response) + */ + knownAliases?: string[]; + knownAliasesLower?: string[]; + playername?: string; + achievementsOneTime?: string[]; + stats: Record; + achievementPoints?: number; + achievements?: Record; + karma?: number; + networkExp?: number; + parkourCheckpointBests?: Record; + parkourCompletions?: Record; + channel?: string; + challenges?: Record; + newPackageRank: string; + levelUp_VIP?: number; + achievementRewardsNew?: Record; + quests?: Record; + levelUp_MVP_PLUS?: number; + currentGadget?: string; + questSettings?: Record; + particlePack?: string; + vanityMeta?: Record; + monthlycrates?: Record; + eugene?: Record; + petConsumables?: Record; + tourney?: Record; + rankPlusColor?: string; + housingMeta?: Record; + mostRecentMonthlyPackageRank?: string; + socialMedia?: Record; + achievementSync?: Record; + lastAdsenseGenerateTime?: number; + lastClaimedReward?: number; + rewardHighScore?: number; + rewardScore?: number; + rewardStreak?: number; + totalDailyRewards?: number; + totalRewards?: number; + currentClickEffect?: string; + disabledProjectileTrails?: boolean; + seasonal?: Record; + adsense_tokens?: number; + monthlyRankColor?: string; + currentPet?: string; + petStats?: Record; + petJourneyTimestamp?: number; + giftingMeta?: Record; + achievementTotem?: Record; + mostRecentGameType?: string; +} + +/** + * The Auction object returned from the API (in JSON) which is converted to the @see {@link SkyBlockAuction} class. + * @category Interfaces + */ +interface APISkyBlockAuction { + _id: string; + id: string; + uuid: string; + auctioneer: string; + profile_id: string; + coop: string[]; + start: number; + end: number; + item_name: string; + item_lore: string; + extra: string; + category: string; + tier: string; + starting_bid: number; + bin: boolean; + item_bytes: { type: number; data: string }; + claimed: boolean; + claimed_bidders: unknown[]; + highest_bid_amount: number; + bids: APISkyBlockAuctionBid[]; +} + +/** + * @category Interfaces + */ +interface APISkyBlockAuctionBid { + auction_id: string; + bidder: string; + profile_id: string; + amount: number; + timestamp: number; +} + +/** + * The Profile object returned from the API (in JSON) which is converted to the @see {@link SkyBlockProfile} class. + * @category Interfaces + */ +interface APISkyBlockProfile { + profile_id: string; + community_upgrades: Record; + + /** + * A map of member UUIDs to member profiles objects + */ + members: APISkyBlockProfileMembers; + + /** + * The cute name of the profile, only provided on the profiles endpoint + */ + cute_name: string | null; + + /** + * Whether or not this is the currently selected profile, only provided on the profiles endpoint + */ + selected: boolean | null; + + /** + * Information about the bank account for this profile, only present if the API banking setting is enabled + */ + banking: APISkyBlockAuctionBanking; + + /** + * The SkyBlock game mode of the profile, not present if normal mode + */ + game_mode: 'ironman' | 'island' | 'bingo'; +} + +/** + * @category Interfaces + */ +interface APISkyBlockProfileMembers { + player_id: string; + /** + * If this field exists, the member profile is marked as deleted + */ + deletion_notice: { + timestamp: number; + }; +} + +/** + * @category Interfaces + */ +interface APISkyBlockAuctionBanking { + balance: number; + transactions: APISkyBlockAuctionBankingTransaction[]; +} + +/** + * @category Interfaces + */ +interface APISkyBlockAuctionBankingTransaction { + timestamp: number; + action: 'DEPOSIT' | 'WITHDRAW'; + initiator_name: string; + amount: number; +} + +/** + * The Museum object returned from the API (in JSON) which is converted to the @see {@link SkyBlockMuseum} class. + * @category Interfaces + */ + +interface APISkyBlockMuseum { + [key: string]: APISkyBlockMuseumMember +} + +interface APISkyBlockMuseumMember { + value: number + appraisal: boolean + items: APISkyBlockMuseumItemObject + special: APISkyBlockMuseumItem[] +} + +interface APISkyBlockMuseumItemObject { + [key: string]: APISkyBlockMuseumItem +} + +/** + * @category Interfaces + */ +interface APISkyBlockMuseumItem { + donated_time: number + items: APISkyBlockMuseumItemItem +} + +/** + * @category Interfaces + */ +interface APISkyBlockMuseumItemItem { + type: number + data: string +} + +/** + * Response returned by mojang API for user uuid lookup + * @category Interfaces + * @see {@link Util.getUUID} + */ +interface GetUUIDResponse { + name: string; + id: string; + errorMessage?: string; +} + +/** + * Response returned by mojang API for user name lookup + * @category Interfaces + * @see {@link Util.getUsername} + */ +interface GetUsernameResponse { + name: string; + uuid: string; + errorMessage?: string; +} + +/** + * Active network boosters returned by the hypixel API + * @category Interfaces + */ +interface ActiveNetworkBoostersResponse { + boosters: ActiveNetworkBoostersResponseActiveBooster; + boosterState: { decrementing: boolean }; +} + +/** + * @category Interfaces + */ +interface ActiveNetworkBoostersResponseActiveBooster { + _id: string; + purchaserUuid: string; + amount: number; + originalLength: number; + length: number; + gameType: number; + dateActivated: number; + stacked: string[] | null; +} + +/** + * @category Interfaces + */ +interface ActiveNetworkBoostersResponseQueuedBooster extends Omit { + stacked: boolean | null; +} + +/** + * Player count returned by hypixel API + * @category Interfaces + */ +interface CurrentPlayerCountsResponse { + playerCount: number; + games: Record }>; +} + +/** + * Current leaderboards returned by the hypixel API + * @category Interfaces + */ +interface CurrentLeaderboardsResponse { + leaderboards: Record; +} + +/** + * Punishment statistics returned by the hypixel API. + * @category Interfaces + */ +interface PunishmentStatisticsResponse { + watchdog_lastMinute: number; + staff_rollingDaily: number; + watchdog_total: number; + watchdog_rollingDaily: number; + staff_total: number; +} + +/** + * Recently played games returned by hypixel API + * @category Interfaces + * @see {@link PlayerManager.getRecentlyPlayedGames} + */ +interface GetRecentlyPlayedGamesResponse { + date: number; + gameType: string; + mode: string; + map: string; + ended: number; +} + +/** + * Status of a player returned by hypixel API + * @category Interfaces + * @see {@link PlayerManager.getStatus} + */ +interface GetStatusResponse { + online: boolean; + gameType: string; + mode: string; + map: string; +} + +/** + * All other responses extend this interface as they have the common property 'lastUpdated'. + * @category Interfaces + */ +interface BaseResourceResponse { + lastUpdated: number; +} + +/** + * Information about hypixel games returned by the hypixel API + * @category Interfaces + * @see {@link ResourceManager.fetchGameInformation} + */ +interface GameInformationResponse extends BaseResourceResponse { + games: Record; +} + +/** + * @category Interfaces + */ +interface GameInformationResponseGame { + id: number; + name: string; + databaseName: string; + modeNames: Record; + legacy?: boolean; + retired?: boolean; +} + +/** + * All achievements returned by the hypixel API. + * @category Interfaces + */ +interface AchievementsResponse extends BaseResourceResponse { + achievements: Record; +} + +/** + * @category Interfaces + */ +interface AchievementsResponseAchievement { + one_time: Record; + tiered: Record; + total_points: number; + total_legacy_points: number; +} + +/** + * @category Interfaces + */ +interface AchievementsResponseAchievementOnetime { + points: number; + name: string; + description: string; + gamePercentUnlocked: number; + globalPercentUnlocked: number; +} + +/** + * @category Interfaces + */ +interface AchievementsResponseAchievementTiered { + name: string; + description: string; + tiers: { tier: number; points: number; amount: number }[]; +} + +/** + * All challenges returned by hypixel API + * @category Interfaces + */ +interface ChallengesResponse extends BaseResourceResponse { + challenges: Record; +} + +/** + * @category Interfaces + */ +interface ChallengesResponseChallenge { + id: string; + name: string; + rewards: { type: string; amount: number }[]; +} + +/** + * All quests returned by the hypixel API + * @category Interfaces + */ +interface QuestsResponse extends BaseResourceResponse { + quests: Record; +} + +/** + * @category Interfaces + */ +interface QuestsResponseQuest { + id: string; + name: string; + description: string; + rewards: { type: string; amount: number }[]; + objectives: { id: string; type: string }[]; + requirements: { type: string }[]; +} + +/** + * All guild achievements returned by the hypixel API + * @category Interfaces + */ +interface GuildAchievementsResponse extends BaseResourceResponse { + one_time: AchievementsResponseAchievementOnetime; + tiered: AchievementsResponseAchievementTiered; +} + +/** + * All vanity pets returned by the hypixel API + * @category Interfaces + */ +interface VanityPetsResponse extends BaseResourceResponse { + types: VanityPetsResponseType[]; + rarities: VanityPetsResponseRarity[]; +} + +/** + * @category Interfaces + */ +interface VanityPetsResponseType { + key: string; + name: string; + rarity: VanityPetsRarity; + package: string; +} + +/** + * @category Interfaces + */ +interface VanityPetsResponseRarity { + name: VanityPetsRarity; + color: string; +} + +/** + * @category Enumerations + */ +declare enum VanityPetsRarity { + COMMON, + RARE, + EPIC, + LEGENDARY +} + +/** + * All vanity companions returned by the hypixel API + * @category Interfaces + */ +interface VanityCompanionsResponse extends VanityPetsResponse {} + +/** + * Information regarding collections returned by the hypixel API. + * @category Interfaces + */ +interface FetchCollectionsResponse extends BaseResourceResponse { + version: string; + collections: Record; +} + +/** + * @category Interfaces + */ +interface FetchCollectionsResponseCollection { + name: string; + items: Record; +} + +/** + * Information regarding skills returned by the hypixel API. + * @category Interfaces + */ +interface FetchSkillsResponse extends BaseResourceResponse { + version: string; + collections: Record; + skills: Record; +} + +/** + * @category Interfaces + */ +interface FetchSkillsResponseCollection { + name: string; + description: string; + maxLevel: number; + levels: Array>; +} + +/** + * @category Interfaces + */ +interface FetchSkillsResponseSkill extends FetchCollectionsResponseCollection {} + +/** + * Information regarding items in the SkyBlock game + * @category Interfaces + */ +interface FetchItemsResponse extends BaseResourceResponse { + items: Array>; +} + +/** + * @category Interfaces + */ +interface FetchItemsResponseItem { + id: string; + name: string; + tier: string; + unstackable: boolean; +} + +/** + * Information regarding the current mayor and ongoing election in SkyBlock + * @category Interfaces + */ +interface FetchElectionAndMayorResponse extends BaseResourceResponse { + mayor: FetchElectionAndMayorResponseMayor; + current?: FetchElectionAndMayorResponseCurrent; +} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseMayor { + key: string; + name: string; + perks: FetchElectionAndMayorResponseMayorPerks[]; + election: FetchElectionAndMayorResponseElection; + current?: FetchElectionAndMayorResponseCurrent; +} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseMayorPerks { + name: string; + description: string; +} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseElection { + year: number; + candidates: FetchElectionAndMayorResponseElectionCandidate[]; +} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseCurrent extends FetchElectionAndMayorResponseElection {} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseElectionCandidate { + key: string; + name: string; + perks: FetchElectionAndMayorResponseMayorPerks[]; + votes: number; +} + +/** + * Information regarding the current bingo event and its goals + * @category Interfaces + */ +interface FetchActiveBingoGoalsResponse extends BaseResourceResponse { + id: number; + goals: FetchActiveBingoGoalsResponseGoal[]; +} + +/** + * @category Interfaces + */ +interface FetchActiveBingoGoalsResponseGoal { + id: string; + name: string; + tiers?: number[]; + progress?: number; + lore?: string; + requiredAmount?: number; +} + +/** + * News returned by hypixel API + * @category Interfaces + */ +interface FetchNewsResponse extends BaseResourceResponse { + items: FetchNewsResponseItem[]; +} + +/** + * @category Interfaces + */ +interface FetchNewsResponseItem { + item: { + material: string; + }; + link: string; + text: string; + title: string; +} + +/** + * Active auctions returned by the hypixel API + * @category Interfaces + */ +interface FetchActiveAuctionsResponse { + lastUpdated: number; + page: number; + totalPages: number; + totalAuctions: number; + auctions: APISkyBlockAuction[]; +} + +/** + * Recently ended auctions returned by the hypixel API + * @category Interfaces + */ +interface RecentlyEndedAuctionsResponse { + lastUpdated: number; + auctions: RecentlyEndedAuctionsResponseAuction[]; +} + +/** + * @category Interfaces + */ +interface RecentlyEndedAuctionsResponseAuction { + auction_id: string; + seller: string; + seller_profile: string; + buyer: string; + timestamp: number; + price: number; + bin: boolean; + item_bytes: string; +} + +/** + * Bazaar items returned by the hypixel API + * @category Interfaces + */ +interface FetchBazaarResponse { + lastUpdated: number; + products: Record; +} + +/** + * @category Interfaces + */ +interface FetchBazaarResponseProduct { + product_id: string; + sell_summary: FetchBazaarResponseProductSellSummary[]; + buy_summary: FetchBazaarResponseProductBuySummary; + quick_status: FetchBazaarResponseProductQuickStatus; +} + +/** + * @category Interfaces + */ +interface FetchBazaarResponseProductSellSummary { + amount: number; + pricePerUnit: number; + orders: number; +} + +/** + * @category Interfaces + */ +interface FetchBazaarResponseProductBuySummary extends FetchBazaarResponseProductSellSummary {} + +/** + * @category Interfaces + */ +interface FetchBazaarResponseProductQuickStatus { + productId: string; + sellPrice: number; + sellVolume: number; + sellMovingWeek: number; + sellOrders: number; + buyPrice: number; + buyVolume: number; + buyMovingWeek: number; + buyOrders: number; +} + +/** + * Bingo data of a player returned by the hypixel API + * @category Interfaces + */ +interface FetchBingoDataResponse { + events: FetchBingoDataResponseEvent[]; +} + +/** + * @category Interfaces + */ +interface FetchBingoDataResponseEvent { + key: number; + points: number; + completed_goals: string[]; +} + +/** + * @category Interfaces + */ +interface FetchFireSalesResponse { + sales: FetchFireSalesResponseFireSale[]; +} + +/** + * @category Interfaces + */ +interface FetchFireSalesResponseFireSale { + /** + * The SkyBlock item ID for this sale + */ + item_id: string; + /** + * The start time in unix milliseconds for the sale + */ + start: number; + /** + * The end time in unix milliseconds for the sale + */ + end: number; + /** + * The amount of items available for this sale + */ + amount: number; + /** + * The price in Gems for this sale + */ + price: number; +} + +/** + * The guild class + * @category Classes + * @group Classes + * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get} + */ +declare class Guild extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client: Client, data: APIGuild); +} + +/** + * Guild related endpoints + * @category Managers + * @group Managers + */ +declare class GuildManager extends BaseManager { + constructor(client: Client); + /** + * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid + * @param identifier The id/name of the guild or the uuid of the player + * @param type The type of identifier you're passing (id/name of guild, player uuid) + */ + fetch(identifier: string, type: 'id' | 'name' | 'player'): Promise; +} + +/** + * Other endpoints + * @category Managers + * @group Managers + * @see {@link https://api.hypixel.net/#tag/Other} + */ +declare class OtherManager extends BaseManager { + constructor(client: Client); + /** + * Fetch all active network boosters + */ + fetchActiveNetworkBoosters(): Promise; + /** + * Fetch current player counts across all games + */ + fetchCurrentPlayerCounts(): Promise; + /** + * Fetch current leaderboards + */ + fetchCurrentLeaderboards(): Promise; + /** + * Fetch punishment statistics + */ + fetchPunishmentStatistics(): Promise; +} + +interface SkyBlockProfile extends APISkyBlockProfile { +} +/** + * The SkyBlockProfile class. + * @category Classes + * @Group Classes + * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get} + */ +declare class SkyBlockProfile extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client: Client, data: APISkyBlockProfile); +} + +interface Player extends APIPlayer { +} +/** + * The player class + * @category Classes + * @group Classes + * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get} + */ +declare class Player extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client: Client, data: APIPlayer); + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + fetchSkyBlockProfiles(): Promise; +} + +interface SkyBlockAuction extends APISkyBlockAuction { +} +/** + * The sky block auction class + * @category Classes + * @group Classes + * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get} + */ +declare class SkyBlockAuction extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client: Client, data: APISkyBlockAuction); +} + +interface SkyBlockMuseum extends APISkyBlockMuseum { +} +/** + * The SkyBlockMuseum class. + * @category Classes + * @Group Classes + */ +declare class SkyBlockMuseum extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client: Client, data: APISkyBlockMuseum); +} + +/** + * Utility functions + * @category Classes + * @group Classes + */ +declare class Util extends Base { + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static getUUID(name: string): Promise; + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static getUsername(uuid: string): Promise; + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid: string): boolean; +} + +/** + * Player related endpoints. + * @category Managers + * @group Managers + */ +declare class PlayerManager extends BaseManager { + constructor(client: Client); + /** + * Fetch a player using their username or uuid + * @param identifier The username/uuid of the player + */ + fetch(identifier: string): Promise; + /** + * Fetch the recently played games of a player + * @param identifier The username/uuid of the player + */ + getRecentlyPlayedGames(identifier: string): Promise; + /** + * Fetch the status of a player + * @param identifier The username/uuid of the player + */ + getStatus(identifier: string): Promise; + /** + * Resolves the username to a uuid for use in requests + * @param identifier The username (or uuid) of the player + */ + private getUUID; +} + +/** + * Resource endpoints. + * + * **Note**: API Key authorization is not required to use this manager. + * + * @category Managers + * @group Managers + */ +declare class ResourceManager extends BaseManager { + constructor(client: Client); + /** + * Fetch information about Hypixel games + */ + fetchGameInformation(): Promise; + /** + * Fetch all achievements + */ + fetchAchievements(): Promise; + /** + * Fetch all challenges + */ + fetchChallenges(): Promise; + /** + * Fetch all quests + */ + fetchQuests(): Promise; + /** + * Fetch all guild achievements + */ + fetchGuildAchievements(): Promise; + /** + * Fetch all vanity pets + */ + fetchVanityPets(): Promise; + /** + * Fetch all vanity companions + */ + fetchVanityCompanions(): Promise; +} + +/** + * Skyblock related endpoints + * @category Managers + * @group Managers + * @see {@link https://api.hypixel.net/#tag/SkyBlock} + */ +declare class SkyBlockManager extends BaseManager { + constructor(client: Client); + /** + * Fetch information regarding collections in the SkyBlock game + */ + fetchCollections(): Promise; + /** + * Fetch information regarding skills in the SkyBlock game + */ + fetchSkills(): Promise; + /** + * Fetch information regarding items in the SkyBlock game + */ + fetchItems(): Promise; + /** + * Fetch information regarding the current mayor and ongoing election in SkyBlock + */ + fetchElectionAndMayor(): Promise; + /** + * Fetch information regarding the current bingo event and its goals + */ + fetchActiveBingoGoals(): Promise; + /** + * Fetch SkyBlock news + */ + fetchNews(): Promise<{ + items: FetchNewsResponseItem[]; + }>; + /** + * Fetch a SkyBlock auction. + * @param identifier The idenitifer you're using to fetch the auction + * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`) + * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`. + */ + fetchAuction(identifier: string, type: 'uuid' | 'player' | 'profile', raw?: boolean): Promise; + /** + * Fetch the currently active auctions (sorted by last updated first and paginated) + * @param page The page number + * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`. + */ + fetchActiveAuctions(page?: number, resolveAuctions?: boolean): Promise<{ + lastUpdated: number; + page: number; + totalPages: number; + totalAuctions: number; + auctions: APISkyBlockAuction[]; + }>; + /** + * Fetch recently ended auctions (auctions which ended in the last 60 seconds). + */ + fetchRecentlyEndedAuctions(): Promise; + /** + * Fetch bazaar items + */ + fetchBazaar(): Promise; + /** + * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + fetchProfile(profileUuid: string): Promise; + /** + * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + fetchMuseum(profileUuid: string): Promise; + /** + * Fetch a SkyBlock profiles of a player + * @param playerUuid The uuid of the player + */ + fetchPlayerSkyBlockProfiles(playerUuid: string): Promise; + /** + * Fetch bingo data of a player + * @param playerUuid The uuid of the player + */ + fetchBingoData(playerUuid: string): Promise; + /** + * Fetch the currently active or upcoming Fire Sales for SkyBlock + */ + fetchFireSales(): Promise; +} + +/** + * The options supplied to the request + * @category Rest + * @group Rest + */ +interface ApiRequestOptions { + /** + * The request path/endpoint + */ + path: string; + /** + * The request method, only `GET` is supported + */ + method?: 'GET'; + /** + * Whether to send the API key for this request + */ + sendAPIKey?: boolean; +} +/** + * Handles (sending/building options) requests + * @category Rest + * @group Rest + */ +declare class ApiRequest { + /** + * The request manager instance + */ + requests: RequestManager; + /** + * The options of this request + */ + options: ApiRequestOptions; + constructor(requestManager: RequestManager, options: ApiRequestOptions); + /** + * Makes a request with the options provided. + */ + make(): Promise; + /** + * Creates an object containing the options to be passed to the request + */ + buildOptions(): { + url: string; + method: "GET"; + headers: Record; + }; +} + +/** + * Manages the requests to the API + * @category Rest + * @group Rest + */ +declare class RequestManager { + /** + * The hypixel.ts client instance + */ + client: Client; + /** + * The base url of the hypixel API + */ + baseApiUrl: string; + /** + * Queue for requests + * @see {@link https://npmjs.com/@sapphire/async-queue} + */ + private queue; + constructor(client: Client); + /** + * Makes the api request and pushes it to the request queue + * @param path The path/endpoint to make the request to + * @param sendAPIKey Whether or not to send the apiKey with this request + */ + execute(path: string, sendAPIKey: boolean): Promise; +} + +/** + * The hypixel.ts client. + * @category Classes + */ +declare class Client { + options?: ClientOptions; + requests: RequestManager; + players: PlayerManager; + guilds: GuildManager; + resources: ResourceManager; + others: OtherManager; + skyblock: SkyBlockManager; + constructor(options?: ClientOptions); + /** + * Starts the hypixel client (registers all managers) + * *NOTE*: This method must be called before further usage. + */ + start(): this; + /** + * Register all the managers + */ + private registerManagers; +} + +/** + * The client options. + * @category Interfaces + */ +interface ClientOptions { + /** + * The hypixel api key. + * This is optional to provide as some managers support non auth requests. + */ + apiKey?: string; + /** + * The base hypixel api url + * @private + */ + baseApiUrl?: string; +} + +export { type APIGuild, type APIGuildMember, type APIGuildRank, type APIPlayer, type APISkyBlockAuction, type APISkyBlockAuctionBanking, type APISkyBlockAuctionBankingTransaction, type APISkyBlockAuctionBid, type APISkyBlockMuseum, type APISkyBlockMuseumItem, type APISkyBlockMuseumItemItem, type APISkyBlockMuseumItemObject, type APISkyBlockMuseumMember, type APISkyBlockProfile, type APISkyBlockProfileMembers, type AchievementsResponse, type AchievementsResponseAchievement, type AchievementsResponseAchievementOnetime, type AchievementsResponseAchievementTiered, type ActiveNetworkBoostersResponse, type ActiveNetworkBoostersResponseActiveBooster, type ActiveNetworkBoostersResponseQueuedBooster, ApiRequest, type ApiRequestOptions, Base, BaseManager, type BaseResourceResponse, type ChallengesResponse, type ChallengesResponseChallenge, Client, type ClientOptions, type CurrentLeaderboardsResponse, type CurrentPlayerCountsResponse, type FetchActiveAuctionsResponse, type FetchActiveBingoGoalsResponse, type FetchActiveBingoGoalsResponseGoal, type FetchBazaarResponse, type FetchBazaarResponseProduct, type FetchBazaarResponseProductBuySummary, type FetchBazaarResponseProductQuickStatus, type FetchBazaarResponseProductSellSummary, type FetchBingoDataResponse, type FetchBingoDataResponseEvent, type FetchCollectionsResponse, type FetchCollectionsResponseCollection, type FetchElectionAndMayorResponse, type FetchElectionAndMayorResponseCurrent, type FetchElectionAndMayorResponseElection, type FetchElectionAndMayorResponseElectionCandidate, type FetchElectionAndMayorResponseMayor, type FetchElectionAndMayorResponseMayorPerks, type FetchFireSalesResponse, type FetchFireSalesResponseFireSale, type FetchItemsResponse, type FetchItemsResponseItem, type FetchNewsResponse, type FetchNewsResponseItem, type FetchSkillsResponse, type FetchSkillsResponseCollection, type FetchSkillsResponseSkill, type GameInformationResponse, type GameInformationResponseGame, type GetRecentlyPlayedGamesResponse, type GetStatusResponse, type GetUUIDResponse, type GetUsernameResponse, Guild, type GuildAchievementsResponse, GuildManager, OtherManager, Player, PlayerManager, type PunishmentStatisticsResponse, type QuestsResponse, type QuestsResponseQuest, type RecentlyEndedAuctionsResponse, type RecentlyEndedAuctionsResponseAuction, RequestManager, ResourceManager, SkyBlockAuction, SkyBlockManager, SkyBlockMuseum, SkyBlockProfile, Util, type VanityCompanionsResponse, VanityPetsRarity, type VanityPetsResponse, type VanityPetsResponseRarity, type VanityPetsResponseType }; diff --git a/dist/cjs/index.js b/dist/cjs/index.js new file mode 100644 index 0000000..79b138a --- /dev/null +++ b/dist/cjs/index.js @@ -0,0 +1,822 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var src_exports = {}; +__export(src_exports, { + ApiRequest: () => ApiRequest, + Base: () => Base, + BaseManager: () => BaseManager, + Client: () => Client, + Guild: () => Guild, + GuildManager: () => GuildManager, + HypixelAPIError: () => HypixelAPIError, + OtherManager: () => OtherManager, + Player: () => Player, + PlayerManager: () => PlayerManager, + RequestManager: () => RequestManager2, + ResourceManager: () => ResourceManager, + SkyBlockAuction: () => SkyBlockAuction, + SkyBlockManager: () => SkyBlockManager, + SkyBlockMuseum: () => SkyBlockMuseum, + SkyBlockProfile: () => SkyBlockProfile, + Util: () => Util, + VanityPetsRarity: () => VanityPetsRarity +}); +module.exports = __toCommonJS(src_exports); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/Guild.ts +var Guild = class extends Base { + static { + __name(this, "Guild"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client, data) { + super(client); + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/managers/GuildManager.ts +var GuildManager = class extends BaseManager { + static { + __name(this, "GuildManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid + * @param identifier The id/name of the guild or the uuid of the player + * @param type The type of identifier you're passing (id/name of guild, player uuid) + */ + async fetch(identifier, type) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "type"); + if (type !== "id" && type !== "name" && type !== "player") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "GuildManager", "fetch", "type", ["id", "name", "player"]); + const { guild } = await this.makeGetRequest(`/guild?${type}=${identifier}`); + return guild ? new Guild(this.client, guild) : null; + } +}; + +// src/lib/managers/OtherManager.ts +var OtherManager = class extends BaseManager { + static { + __name(this, "OtherManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch all active network boosters + */ + async fetchActiveNetworkBoosters() { + const data = await this.makeGetRequest("/boosters"); + return { + boosters: data.boosters, + boosterState: data.boosterState + }; + } + /** + * Fetch current player counts across all games + */ + async fetchCurrentPlayerCounts() { + const data = await this.makeGetRequest("/counts"); + return { + playerCount: data.playerCount, + games: data.games + }; + } + /** + * Fetch current leaderboards + */ + async fetchCurrentLeaderboards() { + const data = await this.makeGetRequest("/leaderboards"); + return { + leaderboards: data.leaderboards + }; + } + /** + * Fetch punishment statistics + */ + async fetchPunishmentStatistics() { + const data = await this.makeGetRequest("/punishmentstats"); + return { + watchdog_lastMinute: data.watchdog_lastMinute, + staff_rollingDaily: data.staff_rollingDaily, + watchdog_total: data.watchdog_total, + watchdog_rollingDaily: data.watchdog_rollingDaily, + staff_total: data.staff_total + }; + } +}; + +// src/lib/classes/Player.ts +var Player = class extends Base { + static { + __name(this, "Player"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + async fetchSkyBlockProfiles() { + return this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid); + } +}; + +// src/lib/classes/SkyBlockAuction.ts +var SkyBlockAuction = class extends Base { + static { + __name(this, "SkyBlockAuction"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client, data) { + super(client); + if ("_id" in data) + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockProfile.ts +var SkyBlockProfile = class extends Base { + static { + __name(this, "SkyBlockProfile"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockMuseum.ts +var SkyBlockMuseum = class extends Base { + static { + __name(this, "SkyBlockMuseum"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/Util.ts +var Util = class extends Base { + static { + __name(this, "Util"); + } + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static async getUUID(name) { + try { + const data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_UUID_ERROR", json.errorMessage, data.status); + return json.id; + } catch { + throw new HypixelTSError("GET_UUID_404"); + } + } + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static async getUsername(uuid) { + if (!this.isUUID(uuid)) { + throw new HypixelTSError("NOT_UUID"); + } + try { + const data = await fetch(`https://api.mojang.com/user/profile/${uuid}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_USERNAME_ERROR", json.errorMessage, data.status); + return json.name; + } catch { + throw new HypixelTSError("GET_USERNAME_404"); + } + } + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid) { + const regexStripped = /^[0-9a-f]{32}$/i; + const regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}$/i; + return regexStripped.test(uuid) || regexFull.test(uuid); + } +}; + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); + +// src/lib/managers/PlayerManager.ts +var PlayerManager = class extends BaseManager { + static { + __name(this, "PlayerManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a player using their username or uuid + * @param identifier The username/uuid of the player + */ + async fetch(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "fetch", "identifier"); + const uuid = await this.getUUID(identifier); + const { player } = await this.makeGetRequest(`/player?uuid=${uuid}`); + return new Player(this.client, player); + } + /** + * Fetch the recently played games of a player + * @param identifier The username/uuid of the player + */ + async getRecentlyPlayedGames(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getRecentlyPlayedGames", "identifier"); + const uuid = await this.getUUID(identifier); + const { games } = await this.makeGetRequest(`/recentgames?uuid=${uuid}`); + return games; + } + /** + * Fetch the status of a player + * @param identifier The username/uuid of the player + */ + async getStatus(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getStatus", "identifier"); + const uuid = await this.getUUID(identifier); + const { session } = await this.makeGetRequest(`/status?uuid=${uuid}`); + return session; + } + /** + * Resolves the username to a uuid for use in requests + * @param identifier The username (or uuid) of the player + */ + async getUUID(identifier) { + const isUUID = Util.isUUID(identifier); + if (!isUUID) { + const uuid = await Util.getUUID(identifier); + return uuid; + } + return identifier; + } +}; + +// src/lib/managers/ResourceManager.ts +var ResourceManager = class extends BaseManager { + static { + __name(this, "ResourceManager"); + } + constructor(client) { + super(client, false); + } + /** + * Fetch information about Hypixel games + */ + async fetchGameInformation() { + return this.makeGetRequest("/resources/games"); + } + /** + * Fetch all achievements + */ + async fetchAchievements() { + return this.makeGetRequest("/resources/achievements"); + } + /** + * Fetch all challenges + */ + async fetchChallenges() { + return this.makeGetRequest("/resources/challenges"); + } + /** + * Fetch all quests + */ + async fetchQuests() { + return this.makeGetRequest("/resources/quests"); + } + /** + * Fetch all guild achievements + */ + async fetchGuildAchievements() { + return this.makeGetRequest("/resources/guilds/achievements"); + } + /** + * Fetch all vanity pets + */ + async fetchVanityPets() { + return this.makeGetRequest("/resources/vanity/pets"); + } + /** + * Fetch all vanity companions + */ + async fetchVanityCompanions() { + return this.makeGetRequest("/resources/vanity/companions"); + } +}; + +// src/lib/managers/SkyBlockManager.ts +var SkyBlockManager = class extends BaseManager { + static { + __name(this, "SkyBlockManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch information regarding collections in the SkyBlock game + */ + async fetchCollections() { + const data = await this.makeGetRequest("/resources/skyblock/collections"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections + }; + } + /** + * Fetch information regarding skills in the SkyBlock game + */ + async fetchSkills() { + const data = await this.makeGetRequest("/resources/skyblock/skills"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections, + skills: data.skills + }; + } + /** + * Fetch information regarding items in the SkyBlock game + */ + async fetchItems() { + const data = await this.makeGetRequest("/resources/skyblock/items"); + return { + lastUpdated: data.lastUpdated, + items: data.items + }; + } + /** + * Fetch information regarding the current mayor and ongoing election in SkyBlock + */ + async fetchElectionAndMayor() { + const data = await this.makeGetRequest("/resources/skyblock/election"); + return { + lastUpdated: data.lastUpdated, + mayor: data.mayor, + current: data.current + }; + } + /** + * Fetch information regarding the current bingo event and its goals + */ + async fetchActiveBingoGoals() { + const data = await this.makeGetRequest("/resources/skyblock/bingo"); + return { + lastUpdated: data.lastUpdated, + id: data.id, + goals: data.goals + }; + } + /** + * Fetch SkyBlock news + */ + async fetchNews() { + const data = await this.makeGetRequest("/skyblock/news"); + return { + items: data.items + }; + } + /** + * Fetch a SkyBlock auction. + * @param identifier The idenitifer you're using to fetch the auction + * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`) + * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`. + */ + async fetchAuction(identifier, type, raw = false) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "type"); + if (type !== "uuid" && type !== "player" && type !== "profile") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchAuction", "type", ["uuid", "player", "profile"]); + const { auctions } = await this.makeGetRequest(`/skyblock/auction?${type}=${identifier}`); + if (!raw) { + const parsed = []; + for (const auction of auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return parsed; + } + return auctions; + } + /** + * Fetch the currently active auctions (sorted by last updated first and paginated) + * @param page The page number + * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`. + */ + async fetchActiveAuctions(page, resolveAuctions = true) { + if (page && typeof page !== "number") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchActiveAuctions", "page", ["number"]); + const data = await this.makeGetRequest(`/skyblock/auctions${page ? "?page=" + page : ""}`); + if (resolveAuctions) { + const parsed = []; + for (const auction of data.auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: parsed + }; + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: data.auctions + }; + } + /** + * Fetch recently ended auctions (auctions which ended in the last 60 seconds). + */ + async fetchRecentlyEndedAuctions() { + const data = await this.makeGetRequest("/skyblock/auctions_ended"); + return { + lastUpdated: data.lastUpdated, + auctions: data.auctions + }; + } + /** + * Fetch bazaar items + */ + async fetchBazaar() { + const data = await this.makeGetRequest("/skyblock/bazaar"); + return { + lastUpdated: data.lastUpdated, + products: data.products + }; + } + /** + * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchProfile(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchProfile", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`); + return new SkyBlockProfile(this.client, data); + } + /** + * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchMuseum(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchMuseum", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`); + return new SkyBlockMuseum(this.client, data); + } + /** + * Fetch a SkyBlock profiles of a player + * @param playerUuid The uuid of the player + */ + async fetchPlayerSkyBlockProfiles(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchPlayerSkyBlockProfiles", "playerUuid"); + const { profiles } = await this.makeGetRequest(`/skyblock/profiles?uuid=${playerUuid}`); + const parsed = []; + for (const profile of profiles) { + parsed.push(new SkyBlockProfile(this.client, profile)); + } + return parsed; + } + /** + * Fetch bingo data of a player + * @param playerUuid The uuid of the player + */ + async fetchBingoData(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchBingoData", "playerUuid"); + const data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`); + return { + events: data.events + }; + } + /** + * Fetch the currently active or upcoming Fire Sales for SkyBlock + */ + async fetchFireSales() { + const { sales } = await this.makeGetRequest("/skyblock/firesales"); + return sales; + } +}; + +// src/lib/rest/ApiRequest.ts +var ApiRequest = class { + static { + __name(this, "ApiRequest"); + } + /** + * The request manager instance + */ + requests; + /** + * The options of this request + */ + options; + constructor(requestManager, options) { + this.requests = requestManager; + this.options = options; + } + /** + * Makes a request with the options provided. + */ + async make() { + const options = this.buildOptions(); + const res = await fetch(options.url, { + ...options + }); + if (!res.ok) { + const error = await res.json(); + throw new HypixelAPIError(error?.cause ?? res.statusText, res.status); + } + return res; + } + /** + * Creates an object containing the options to be passed to the request + */ + buildOptions() { + const apiKey = this.requests.client.options?.apiKey; + const headers = { + "Content-Type": "application/json" + }; + if (this.options.sendAPIKey) { + if (!apiKey) + throw new HypixelTSError("CLIENT_OPTIONS_MISSING", "apiKey"); + headers["API-Key"] = apiKey; + } + const options = { + url: `${this.requests.baseApiUrl}${this.options.path}`, + method: this.options.method ?? "GET", + headers + }; + return options; + } +}; + +// src/lib/rest/HypixelAPIError.ts +var HypixelAPIError = class extends Error { + static { + __name(this, "HypixelAPIError"); + } + code; + constructor(message, code) { + super(message); + this.message = message; + this.code = code; + } +}; + +// src/lib/rest/RequestManager.ts +var import_async_queue = require("@sapphire/async-queue"); +var RequestManager2 = class { + static { + __name(this, "RequestManager"); + } + /** + * The hypixel.ts client instance + */ + client; + /** + * The base url of the hypixel API + */ + baseApiUrl; + /** + * Queue for requests + * @see {@link https://npmjs.com/@sapphire/async-queue} + */ + queue; + constructor(client) { + this.client = client; + this.baseApiUrl = client.options?.baseApiUrl ?? "https://api.hypixel.net"; + this.queue = new import_async_queue.AsyncQueue(); + } + /** + * Makes the api request and pushes it to the request queue + * @param path The path/endpoint to make the request to + * @param sendAPIKey Whether or not to send the apiKey with this request + */ + async execute(path, sendAPIKey) { + await this.queue.wait(); + try { + const request = await new ApiRequest(this, { path, sendAPIKey }).make(); + return request.json(); + } finally { + this.queue.shift(); + } + } +}; + +// src/lib/Client.ts +var Client = class { + static { + __name(this, "Client"); + } + options; + requests; + players; + guilds; + resources; + others; + skyblock; + constructor(options) { + this.options = options ?? {}; + this.options.baseApiUrl = "https://api.hypixel.net"; + } + /** + * Starts the hypixel client (registers all managers) + * *NOTE*: This method must be called before further usage. + */ + start() { + this.registerManagers(); + return this; + } + /** + * Register all the managers + */ + registerManagers() { + this.requests = new RequestManager2(this); + this.players = new PlayerManager(this); + this.guilds = new GuildManager(this); + this.resources = new ResourceManager(this); + this.others = new OtherManager(this); + this.skyblock = new SkyBlockManager(this); + } +}; + +// src/lib/typings/managers/ResourceManager.d.ts +var VanityPetsRarity = /* @__PURE__ */ ((VanityPetsRarity2) => { + VanityPetsRarity2[VanityPetsRarity2["COMMON"] = 0] = "COMMON"; + VanityPetsRarity2[VanityPetsRarity2["RARE"] = 1] = "RARE"; + VanityPetsRarity2[VanityPetsRarity2["EPIC"] = 2] = "EPIC"; + VanityPetsRarity2[VanityPetsRarity2["LEGENDARY"] = 3] = "LEGENDARY"; + return VanityPetsRarity2; +})(VanityPetsRarity || {}); +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + ApiRequest, + Base, + BaseManager, + Client, + Guild, + GuildManager, + HypixelAPIError, + OtherManager, + Player, + PlayerManager, + RequestManager, + ResourceManager, + SkyBlockAuction, + SkyBlockManager, + SkyBlockMuseum, + SkyBlockProfile, + Util, + VanityPetsRarity +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/cjs/index.js.map b/dist/cjs/index.js.map new file mode 100644 index 0000000..0eb8f32 --- /dev/null +++ b/dist/cjs/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/index.ts","../../src/lib/managers/BaseManager.ts","../../src/lib/errors/HypixelTSError.ts","../../src/lib/classes/Base.ts","../../src/lib/classes/Guild.ts","../../src/lib/managers/GuildManager.ts","../../src/lib/managers/OtherManager.ts","../../src/lib/classes/Player.ts","../../src/lib/classes/SkyBlockAuction.ts","../../src/lib/classes/SkyBlockProfile.ts","../../src/lib/classes/SkyBlockMuseum.ts","../../src/lib/classes/Util.ts","../../src/lib/errors/Messages.ts","../../src/lib/managers/PlayerManager.ts","../../src/lib/managers/ResourceManager.ts","../../src/lib/managers/SkyBlockManager.ts","../../src/lib/rest/ApiRequest.ts","../../src/lib/rest/HypixelAPIError.ts","../../src/lib/rest/RequestManager.ts","../../src/lib/Client.ts","../../src/lib/typings/managers/ResourceManager.d.ts"],"sourcesContent":["export * from './lib/index';\r\n\r\n/**\r\n * The client options.\r\n * @category Interfaces\r\n */\r\nexport interface ClientOptions {\r\n\t/**\r\n\t * The hypixel api key.\r\n\t * This is optional to provide as some managers support non auth requests.\r\n\t */\r\n\tapiKey?: string;\r\n\r\n\t/**\r\n\t * The base hypixel api url\r\n\t * @private\r\n\t */\r\n\tbaseApiUrl?: string;\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APIGuild } from '../typings';\r\n\r\n/**\r\n * The guild class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get}\r\n */\r\nexport class Guild extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Guild data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIGuild) {\r\n\t\tsuper(client);\r\n\t\tdata.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport { Guild } from '../classes/Guild';\r\nimport type { APIGuild } from '../typings';\r\nimport type { Client } from '../Client';\r\n\r\n/**\r\n * Guild related endpoints\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class GuildManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid\r\n\t * @param identifier The id/name of the guild or the uuid of the player\r\n\t * @param type The type of identifier you're passing (id/name of guild, player uuid)\r\n\t */\r\n\tpublic async fetch(identifier: string, type: 'id' | 'name' | 'player') {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'type');\r\n\t\tif (type !== 'id' && type !== 'name' && type !== 'player')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'GuildManager', 'fetch', 'type', ['id', 'name', 'player']);\r\n\r\n\t\tconst { guild } = await this.makeGetRequest<{ guild: APIGuild | null }>(`/guild?${type}=${identifier}`);\r\n\t\treturn guild ? new Guild(this.client, guild) : null;\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport type {\r\n\tActiveNetworkBoostersResponse,\r\n\tCurrentPlayerCountsResponse,\r\n\tCurrentLeaderboardsResponse,\r\n\tPunishmentStatisticsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Other endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/Other}\r\n */\r\nexport class OtherManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all active network boosters\r\n\t */\r\n\tpublic async fetchActiveNetworkBoosters(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/boosters');\r\n\t\treturn {\r\n\t\t\tboosters: data.boosters,\r\n\t\t\tboosterState: data.boosterState\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current player counts across all games\r\n\t */\r\n\tpublic async fetchCurrentPlayerCounts(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/counts');\r\n\t\treturn {\r\n\t\t\tplayerCount: data.playerCount,\r\n\t\t\tgames: data.games\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current leaderboards\r\n\t */\r\n\tpublic async fetchCurrentLeaderboards(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/leaderboards');\r\n\t\treturn {\r\n\t\t\tleaderboards: data.leaderboards\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch punishment statistics\r\n\t */\r\n\tpublic async fetchPunishmentStatistics(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/punishmentstats');\r\n\t\treturn {\r\n\t\t\twatchdog_lastMinute: data.watchdog_lastMinute,\r\n\t\t\tstaff_rollingDaily: data.staff_rollingDaily,\r\n\t\t\twatchdog_total: data.watchdog_total,\r\n\t\t\twatchdog_rollingDaily: data.watchdog_rollingDaily,\r\n\t\t\tstaff_total: data.staff_total\r\n\t\t};\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { Client } from '../Client';\r\nimport { APIPlayer } from '../typings';\r\n\r\nexport interface Player extends APIPlayer {}\r\n/**\r\n * The player class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get}\r\n */\r\nexport class Player extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Player data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIPlayer) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the SkyBlock profiles of this player\r\n\t * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles}\r\n\t */\r\n\tpublic async fetchSkyBlockProfiles() {\r\n\t\treturn this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockAuction } from '../typings';\r\n\r\nexport interface SkyBlockAuction extends APISkyBlockAuction {}\r\n/**\r\n * The sky block auction class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get}\r\n */\r\nexport class SkyBlockAuction extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock auction data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockAuction) {\r\n\t\tsuper(client);\r\n\t\tif ('_id' in data) data.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockProfile } from '../typings';\r\n\r\nexport interface SkyBlockProfile extends APISkyBlockProfile {}\r\n/**\r\n * The SkyBlockProfile class.\r\n * @category Classes\r\n * @Group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get}\r\n */\r\nexport class SkyBlockProfile extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockProfile) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockMuseum } from '../typings';\r\n\r\nexport interface SkyBlockMuseum extends APISkyBlockMuseum {}\r\n/**\r\n * The SkyBlockMuseum class.\r\n * @category Classes\r\n * @Group Classes\r\n */\r\nexport class SkyBlockMuseum extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockMuseum) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport type { GetUsernameResponse, GetUUIDResponse } from '../typings';\r\n\r\n/**\r\n * Utility functions\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Util extends Base {\r\n\t/**\r\n\t * Get the UUID of a player by providing their name\r\n\t * @param name The name of the player\r\n\t */\r\n\tpublic static async getUUID(name: string): Promise {\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`);\r\n\t\t\tconst json = (await data.json()) as GetUUIDResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_UUID_ERROR', json.errorMessage, data.status);\r\n\t\t\treturn json.id;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_UUID_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Get player's name from their UUID\r\n\t * @param uuid The uuid of the player\r\n\t */\r\n\tpublic static async getUsername(uuid: string): Promise {\r\n\t\tif (!this.isUUID(uuid)) {\r\n\t\t\tthrow new HypixelTSError('NOT_UUID');\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/user/profile/${uuid}`);\r\n\t\t\tconst json = (await data.json()) as GetUsernameResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_USERNAME_ERROR', json.errorMessage, data.status);\r\n\r\n\t\t\treturn json.name;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_USERNAME_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Check whether the provided UUID is a valid UUID or not\r\n\t * @param uuid The UUID to check\r\n\t */\r\n\tpublic static isUUID(uuid: string) {\r\n\t\tconst regexStripped = /^[0-9a-f]{32}$/i;\r\n\t\tconst regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}$/i;\r\n\t\treturn regexStripped.test(uuid) || regexFull.test(uuid);\r\n\t}\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n","import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport { Player, Util } from '../classes/index';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport type { APIPlayer, GetRecentlyPlayedGamesResponse, GetStatusResponse } from '../typings';\r\n\r\n/**\r\n * Player related endpoints.\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class PlayerManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a player using their username or uuid\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async fetch(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'fetch', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { player } = await this.makeGetRequest<{ player: APIPlayer }>(`/player?uuid=${uuid}`);\r\n\t\treturn new Player(this.client, player);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the recently played games of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getRecentlyPlayedGames(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getRecentlyPlayedGames', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { games } = await this.makeGetRequest<{ games: GetRecentlyPlayedGamesResponse[] }>(`/recentgames?uuid=${uuid}`);\r\n\t\treturn games;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the status of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getStatus(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getStatus', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { session } = await this.makeGetRequest<{ session: GetStatusResponse }>(`/status?uuid=${uuid}`);\r\n\t\treturn session;\r\n\t}\r\n\r\n\t/**\r\n\t * Resolves the username to a uuid for use in requests\r\n\t * @param identifier The username (or uuid) of the player\r\n\t */\r\n\tprivate async getUUID(identifier: string) {\r\n\t\tconst isUUID = Util.isUUID(identifier);\r\n\r\n\t\tif (!isUUID) {\r\n\t\t\tconst uuid = await Util.getUUID(identifier);\r\n\t\t\treturn uuid;\r\n\t\t}\r\n\r\n\t\treturn identifier;\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport type { Client } from '../Client';\r\nimport type {\r\n\tVanityPetsResponse,\r\n\tAchievementsResponse,\r\n\tChallengesResponse,\r\n\tGameInformationResponse,\r\n\tGuildAchievementsResponse,\r\n\tQuestsResponse,\r\n\tVanityCompanionsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Resource endpoints.\r\n *\r\n * **Note**: API Key authorization is not required to use this manager.\r\n *\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class ResourceManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, false);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information about Hypixel games\r\n\t */\r\n\tpublic async fetchGameInformation() {\r\n\t\treturn this.makeGetRequest('/resources/games');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all achievements\r\n\t */\r\n\tpublic async fetchAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all challenges\r\n\t */\r\n\tpublic async fetchChallenges() {\r\n\t\treturn this.makeGetRequest('/resources/challenges');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all quests\r\n\t */\r\n\tpublic async fetchQuests() {\r\n\t\treturn this.makeGetRequest('/resources/quests');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all guild achievements\r\n\t */\r\n\tpublic async fetchGuildAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/guilds/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity pets\r\n\t */\r\n\tpublic async fetchVanityPets() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/pets');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity companions\r\n\t */\r\n\tpublic async fetchVanityCompanions() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/companions');\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport { SkyBlockProfile, SkyBlockAuction, SkyBlockMuseum } from '../classes/index';\r\nimport type { Client } from '../Client';\r\nimport {\r\n\ttype APISkyBlockProfile,\r\n\ttype FetchCollectionsResponse,\r\n\ttype FetchSkillsResponse,\r\n\ttype FetchItemsResponse,\r\n\ttype FetchElectionAndMayorResponse,\r\n\ttype FetchActiveBingoGoalsResponse,\r\n\ttype FetchNewsResponse,\r\n\ttype APISkyBlockAuction,\r\n\ttype FetchActiveAuctionsResponse,\r\n\ttype FetchBazaarResponse,\r\n\ttype RecentlyEndedAuctionsResponse,\r\n\ttype FetchBingoDataResponse,\r\n\ttype FetchFireSalesResponse,\r\n\ttype FetchFireSalesResponseFireSale,\r\n\tAPISkyBlockMuseum\r\n} from '../typings';\r\n\r\n/**\r\n * Skyblock related endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock}\r\n */\r\nexport class SkyBlockManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding collections in the SkyBlock game\r\n\t */\r\n\tpublic async fetchCollections(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/collections');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding skills in the SkyBlock game\r\n\t */\r\n\tpublic async fetchSkills(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/skills');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections,\r\n\t\t\tskills: data.skills\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding items in the SkyBlock game\r\n\t */\r\n\tpublic async fetchItems(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/items');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current mayor and ongoing election in SkyBlock\r\n\t */\r\n\tpublic async fetchElectionAndMayor(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/election');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tmayor: data.mayor,\r\n\t\t\tcurrent: data.current\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current bingo event and its goals\r\n\t */\r\n\tpublic async fetchActiveBingoGoals(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/bingo');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tid: data.id,\r\n\t\t\tgoals: data.goals\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch SkyBlock news\r\n\t */\r\n\tpublic async fetchNews() {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/news');\r\n\t\treturn {\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock auction.\r\n\t * @param identifier The idenitifer you're using to fetch the auction\r\n\t * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`)\r\n\t * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`.\r\n\t */\r\n\tpublic async fetchAuction(\r\n\t\tidentifier: string,\r\n\t\ttype: 'uuid' | 'player' | 'profile',\r\n\t\traw = false\r\n\t): Promise {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'type');\r\n\t\tif (type !== 'uuid' && type !== 'player' && type !== 'profile')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchAuction', 'type', ['uuid', 'player', 'profile']);\r\n\r\n\t\tconst { auctions } = await this.makeGetRequest<{ auctions: APISkyBlockAuction[] }>(`/skyblock/auction?${type}=${identifier}`);\r\n\r\n\t\tif (!raw) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn parsed;\r\n\t\t}\r\n\r\n\t\treturn auctions;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active auctions (sorted by last updated first and paginated)\r\n\t * @param page The page number\r\n\t * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`.\r\n\t */\r\n\tpublic async fetchActiveAuctions(page?: number, resolveAuctions = true) {\r\n\t\tif (page && typeof page !== 'number')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchActiveAuctions', 'page', ['number']);\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/auctions${page ? '?page=' + page : ''}`);\r\n\r\n\t\tif (resolveAuctions) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of data.auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn {\r\n\t\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\t\tpage: data.page,\r\n\t\t\t\ttotalPages: data.totalPages,\r\n\t\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\t\tauctions: parsed\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tpage: data.page,\r\n\t\t\ttotalPages: data.totalPages,\r\n\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch recently ended auctions (auctions which ended in the last 60 seconds).\r\n\t */\r\n\tpublic async fetchRecentlyEndedAuctions(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/auctions_ended');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bazaar items\r\n\t */\r\n\tpublic async fetchBazaar(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/bazaar');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tproducts: data.products\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchProfile(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchProfile', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockProfile(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchMuseum(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchMuseum', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockMuseum(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profiles of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchPlayerSkyBlockProfiles(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchPlayerSkyBlockProfiles', 'playerUuid');\r\n\r\n\t\tconst { profiles } = await this.makeGetRequest<{ profiles: APISkyBlockProfile[] }>(`/skyblock/profiles?uuid=${playerUuid}`);\r\n\t\tconst parsed = [];\r\n\r\n\t\tfor (const profile of profiles) {\r\n\t\t\tparsed.push(new SkyBlockProfile(this.client, profile));\r\n\t\t}\r\n\r\n\t\treturn parsed;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bingo data of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchBingoData(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchBingoData', 'playerUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`);\r\n\t\treturn {\r\n\t\t\tevents: data.events\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active or upcoming Fire Sales for SkyBlock\r\n\t */\r\n\tpublic async fetchFireSales(): Promise {\r\n\t\tconst { sales } = await this.makeGetRequest('/skyblock/firesales');\r\n\t\treturn sales;\r\n\t}\r\n}\r\n","import { RequestManager, HypixelAPIError, type HypixelAPIErrorResponse } from './index';\r\nimport { HypixelTSError } from '../errors/index';\r\n\r\n/**\r\n * The options supplied to the request\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface ApiRequestOptions {\r\n\t/**\r\n\t * The request path/endpoint\r\n\t */\r\n\tpath: string;\r\n\r\n\t/**\r\n\t * The request method, only `GET` is supported\r\n\t */\r\n\tmethod?: 'GET';\r\n\r\n\t/**\r\n\t * Whether to send the API key for this request\r\n\t */\r\n\tsendAPIKey?: boolean;\r\n}\r\n\r\n/**\r\n * Handles (sending/building options) requests\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class ApiRequest {\r\n\t/**\r\n\t * The request manager instance\r\n\t */\r\n\tpublic requests: RequestManager;\r\n\r\n\t/**\r\n\t * The options of this request\r\n\t */\r\n\tpublic options: ApiRequestOptions;\r\n\r\n\tpublic constructor(requestManager: RequestManager, options: ApiRequestOptions) {\r\n\t\tthis.requests = requestManager;\r\n\t\tthis.options = options;\r\n\t}\r\n\r\n\t/**\r\n\t * Makes a request with the options provided.\r\n\t */\r\n\tpublic async make() {\r\n\t\tconst options = this.buildOptions();\r\n\r\n\t\tconst res = await fetch(options.url, {\r\n\t\t\t...options\r\n\t\t});\r\n\r\n\t\tif (!res.ok) {\r\n\t\t\tconst error = (await res.json()) as HypixelAPIErrorResponse;\r\n\t\t\tthrow new HypixelAPIError(error?.cause ?? res.statusText, res.status);\r\n\t\t}\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an object containing the options to be passed to the request\r\n\t */\r\n\tpublic buildOptions() {\r\n\t\tconst apiKey = this.requests.client.options?.apiKey;\r\n\r\n\t\tconst headers: Record = {\r\n\t\t\t'Content-Type': 'application/json'\r\n\t\t};\r\n\r\n\t\tif (this.options.sendAPIKey) {\r\n\t\t\tif (!apiKey) throw new HypixelTSError('CLIENT_OPTIONS_MISSING', 'apiKey');\r\n\t\t\theaders['API-Key'] = apiKey;\r\n\t\t}\r\n\r\n\t\tconst options = {\r\n\t\t\turl: `${this.requests.baseApiUrl}${this.options.path}`,\r\n\t\t\tmethod: this.options.method ?? 'GET',\r\n\t\t\theaders\r\n\t\t};\r\n\r\n\t\treturn options;\r\n\t}\r\n}\r\n","/**\r\n * Response body when an error is returned by the hypixel api\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface HypixelAPIErrorResponse {\r\n\t/**\r\n\t * Whether or not the request is successful\r\n\t */\r\n\tsuccess: boolean;\r\n\r\n\t/**\r\n\t * The message explaining the error\r\n\t */\r\n\tcause: string;\r\n}\r\n\r\n/**\r\n * Error thrown when an error is encountered while querying the hypixel API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class HypixelAPIError extends Error {\r\n\tpublic code: number;\r\n\r\n\tpublic constructor(message: string, code: number) {\r\n\t\tsuper(message);\r\n\t\tthis.message = message;\r\n\t\tthis.code = code;\r\n\t}\r\n}\r\n","import { AsyncQueue } from '@sapphire/async-queue';\r\nimport { ApiRequest } from './ApiRequest';\r\nimport { Client } from '../Client';\r\n\r\n/**\r\n * Manages the requests to the API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class RequestManager {\r\n\t/**\r\n\t * The hypixel.ts client instance\r\n\t */\r\n\tpublic client: Client;\r\n\r\n\t/**\r\n\t * The base url of the hypixel API\r\n\t */\r\n\tpublic baseApiUrl: string;\r\n\r\n\t/**\r\n\t * Queue for requests\r\n\t * @see {@link https://npmjs.com/@sapphire/async-queue}\r\n\t */\r\n\tprivate queue: AsyncQueue;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t\tthis.baseApiUrl = client.options?.baseApiUrl ?? 'https://api.hypixel.net';\r\n\t\tthis.queue = new AsyncQueue();\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the api request and pushes it to the request queue\r\n\t * @param path The path/endpoint to make the request to\r\n\t * @param sendAPIKey Whether or not to send the apiKey with this request\r\n\t */\r\n\tpublic async execute(path: string, sendAPIKey: boolean) {\r\n\t\tawait this.queue.wait();\r\n\t\ttry {\r\n\t\t\tconst request = await new ApiRequest(this, { path, sendAPIKey }).make();\r\n\t\t\treturn request.json() as T;\r\n\t\t} finally {\r\n\t\t\tthis.queue.shift();\r\n\t\t}\r\n\t}\r\n}\r\n","import { PlayerManager, GuildManager, ResourceManager, OtherManager, SkyBlockManager } from './managers/index';\r\nimport { RequestManager } from './rest/index';\r\nimport type { ClientOptions } from '../index';\r\n\r\n/**\r\n * The hypixel.ts client.\r\n * @category Classes\r\n */\r\nexport class Client {\r\n\tpublic options?: ClientOptions;\r\n\tpublic requests!: RequestManager;\r\n\tpublic players!: PlayerManager;\r\n\tpublic guilds!: GuildManager;\r\n\tpublic resources!: ResourceManager;\r\n\tpublic others!: OtherManager;\r\n\tpublic skyblock!: SkyBlockManager;\r\n\r\n\tpublic constructor(options?: ClientOptions) {\r\n\t\tthis.options = options ?? {};\r\n\t\tthis.options.baseApiUrl = 'https://api.hypixel.net';\r\n\t}\r\n\r\n\t/**\r\n\t * Starts the hypixel client (registers all managers)\r\n\t * *NOTE*: This method must be called before further usage.\r\n\t */\r\n\tpublic start() {\r\n\t\tthis.registerManagers();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Register all the managers\r\n\t */\r\n\tprivate registerManagers() {\r\n\t\tthis.requests = new RequestManager(this);\r\n\t\tthis.players = new PlayerManager(this);\r\n\t\tthis.guilds = new GuildManager(this);\r\n\t\tthis.resources = new ResourceManager(this);\r\n\t\tthis.others = new OtherManager(this);\r\n\t\tthis.skyblock = new SkyBlockManager(this);\r\n\t}\r\n}\r\n","/**\r\n * All other responses extend this interface as they have the common property 'lastUpdated'.\r\n * @category Interfaces\r\n */\r\nexport interface BaseResourceResponse {\r\n\tlastUpdated: number;\r\n}\r\n\r\n/**\r\n * Information about hypixel games returned by the hypixel API\r\n * @category Interfaces\r\n * @see {@link ResourceManager.fetchGameInformation}\r\n */\r\nexport interface GameInformationResponse extends BaseResourceResponse {\r\n\tgames: Record;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface GameInformationResponseGame {\r\n\tid: number;\r\n\tname: string;\r\n\tdatabaseName: string;\r\n\tmodeNames: Record;\r\n\tlegacy?: boolean;\r\n\tretired?: boolean;\r\n}\r\n\r\n/**\r\n * All achievements returned by the hypixel API.\r\n * @category Interfaces\r\n */\r\nexport interface AchievementsResponse extends BaseResourceResponse {\r\n\tachievements: Record;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface AchievementsResponseAchievement {\r\n\tone_time: Record;\r\n\ttiered: Record;\r\n\ttotal_points: number;\r\n\ttotal_legacy_points: number;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface AchievementsResponseAchievementOnetime {\r\n\tpoints: number;\r\n\tname: string;\r\n\tdescription: string;\r\n\tgamePercentUnlocked: number;\r\n\tglobalPercentUnlocked: number;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface AchievementsResponseAchievementTiered {\r\n\tname: string;\r\n\tdescription: string;\r\n\ttiers: { tier: number; points: number; amount: number }[];\r\n}\r\n\r\n/**\r\n * All challenges returned by hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface ChallengesResponse extends BaseResourceResponse {\r\n\tchallenges: Record;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface ChallengesResponseChallenge {\r\n\tid: string;\r\n\tname: string;\r\n\trewards: { type: string; amount: number }[];\r\n}\r\n\r\n/**\r\n * All quests returned by the hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface QuestsResponse extends BaseResourceResponse {\r\n\tquests: Record;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface QuestsResponseQuest {\r\n\tid: string;\r\n\tname: string;\r\n\tdescription: string;\r\n\trewards: { type: string; amount: number }[];\r\n\tobjectives: { id: string; type: string }[];\r\n\trequirements: { type: string }[];\r\n}\r\n\r\n/**\r\n * All guild achievements returned by the hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface GuildAchievementsResponse extends BaseResourceResponse {\r\n\tone_time: AchievementsResponseAchievementOnetime;\r\n\ttiered: AchievementsResponseAchievementTiered;\r\n}\r\n\r\n/**\r\n * All vanity pets returned by the hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface VanityPetsResponse extends BaseResourceResponse {\r\n\ttypes: VanityPetsResponseType[];\r\n\trarities: VanityPetsResponseRarity[];\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface VanityPetsResponseType {\r\n\tkey: string;\r\n\tname: string;\r\n\trarity: VanityPetsRarity;\r\n\tpackage: string;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface VanityPetsResponseRarity {\r\n\tname: VanityPetsRarity;\r\n\tcolor: string;\r\n}\r\n\r\n/**\r\n * @category Enumerations\r\n */\r\nexport enum VanityPetsRarity {\r\n\tCOMMON,\r\n\tRARE,\r\n\tEPIC,\r\n\tLEGENDARY\r\n}\r\n\r\n/**\r\n * All vanity companions returned by the hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface VanityCompanionsResponse extends VanityPetsResponse {}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,cAAN,MAAkB;AAAA,EAPzB,OAOyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAId;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEH,YAAY,QAAgB,cAAuB;AACzD,SAAK,SAAS;AACd,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAgB,eAAkB,MAAc;AAC/C,WAAO,KAAK,OAAO,SAAS,QAAW,MAAM,KAAK,YAAY;AAAA,EAC/D;AACD;;;AC/BA,IAAM,WAAW,oBAAI,IAA2C;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ACD;;;ACqGO,IAAK,mBAAL,kBAAKC,sBAAL;AACN,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AAJW,SAAAA;AAAA,GAAA;","names":["RequestManager","key","args","messages","RequestManager","RequestManager","VanityPetsRarity"]} \ No newline at end of file diff --git a/dist/cjs/lib/Client.d.ts b/dist/cjs/lib/Client.d.ts new file mode 100644 index 0000000..9f2cd93 --- /dev/null +++ b/dist/cjs/lib/Client.d.ts @@ -0,0 +1,2 @@ +export { Client } from '../index.js'; +import './rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/Client.js b/dist/cjs/lib/Client.js new file mode 100644 index 0000000..ec092a0 --- /dev/null +++ b/dist/cjs/lib/Client.js @@ -0,0 +1,779 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/Client.ts +var Client_exports = {}; +__export(Client_exports, { + Client: () => Client +}); +module.exports = __toCommonJS(Client_exports); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/Guild.ts +var Guild = class extends Base { + static { + __name(this, "Guild"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client, data) { + super(client); + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/managers/GuildManager.ts +var GuildManager = class extends BaseManager { + static { + __name(this, "GuildManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid + * @param identifier The id/name of the guild or the uuid of the player + * @param type The type of identifier you're passing (id/name of guild, player uuid) + */ + async fetch(identifier, type) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "type"); + if (type !== "id" && type !== "name" && type !== "player") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "GuildManager", "fetch", "type", ["id", "name", "player"]); + const { guild } = await this.makeGetRequest(`/guild?${type}=${identifier}`); + return guild ? new Guild(this.client, guild) : null; + } +}; + +// src/lib/managers/OtherManager.ts +var OtherManager = class extends BaseManager { + static { + __name(this, "OtherManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch all active network boosters + */ + async fetchActiveNetworkBoosters() { + const data = await this.makeGetRequest("/boosters"); + return { + boosters: data.boosters, + boosterState: data.boosterState + }; + } + /** + * Fetch current player counts across all games + */ + async fetchCurrentPlayerCounts() { + const data = await this.makeGetRequest("/counts"); + return { + playerCount: data.playerCount, + games: data.games + }; + } + /** + * Fetch current leaderboards + */ + async fetchCurrentLeaderboards() { + const data = await this.makeGetRequest("/leaderboards"); + return { + leaderboards: data.leaderboards + }; + } + /** + * Fetch punishment statistics + */ + async fetchPunishmentStatistics() { + const data = await this.makeGetRequest("/punishmentstats"); + return { + watchdog_lastMinute: data.watchdog_lastMinute, + staff_rollingDaily: data.staff_rollingDaily, + watchdog_total: data.watchdog_total, + watchdog_rollingDaily: data.watchdog_rollingDaily, + staff_total: data.staff_total + }; + } +}; + +// src/lib/classes/Player.ts +var Player = class extends Base { + static { + __name(this, "Player"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + async fetchSkyBlockProfiles() { + return this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid); + } +}; + +// src/lib/classes/SkyBlockAuction.ts +var SkyBlockAuction = class extends Base { + static { + __name(this, "SkyBlockAuction"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client, data) { + super(client); + if ("_id" in data) + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockProfile.ts +var SkyBlockProfile = class extends Base { + static { + __name(this, "SkyBlockProfile"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockMuseum.ts +var SkyBlockMuseum = class extends Base { + static { + __name(this, "SkyBlockMuseum"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/Util.ts +var Util = class extends Base { + static { + __name(this, "Util"); + } + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static async getUUID(name) { + try { + const data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_UUID_ERROR", json.errorMessage, data.status); + return json.id; + } catch { + throw new HypixelTSError("GET_UUID_404"); + } + } + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static async getUsername(uuid) { + if (!this.isUUID(uuid)) { + throw new HypixelTSError("NOT_UUID"); + } + try { + const data = await fetch(`https://api.mojang.com/user/profile/${uuid}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_USERNAME_ERROR", json.errorMessage, data.status); + return json.name; + } catch { + throw new HypixelTSError("GET_USERNAME_404"); + } + } + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid) { + const regexStripped = /^[0-9a-f]{32}$/i; + const regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}$/i; + return regexStripped.test(uuid) || regexFull.test(uuid); + } +}; + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); + +// src/lib/managers/PlayerManager.ts +var PlayerManager = class extends BaseManager { + static { + __name(this, "PlayerManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a player using their username or uuid + * @param identifier The username/uuid of the player + */ + async fetch(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "fetch", "identifier"); + const uuid = await this.getUUID(identifier); + const { player } = await this.makeGetRequest(`/player?uuid=${uuid}`); + return new Player(this.client, player); + } + /** + * Fetch the recently played games of a player + * @param identifier The username/uuid of the player + */ + async getRecentlyPlayedGames(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getRecentlyPlayedGames", "identifier"); + const uuid = await this.getUUID(identifier); + const { games } = await this.makeGetRequest(`/recentgames?uuid=${uuid}`); + return games; + } + /** + * Fetch the status of a player + * @param identifier The username/uuid of the player + */ + async getStatus(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getStatus", "identifier"); + const uuid = await this.getUUID(identifier); + const { session } = await this.makeGetRequest(`/status?uuid=${uuid}`); + return session; + } + /** + * Resolves the username to a uuid for use in requests + * @param identifier The username (or uuid) of the player + */ + async getUUID(identifier) { + const isUUID = Util.isUUID(identifier); + if (!isUUID) { + const uuid = await Util.getUUID(identifier); + return uuid; + } + return identifier; + } +}; + +// src/lib/managers/ResourceManager.ts +var ResourceManager = class extends BaseManager { + static { + __name(this, "ResourceManager"); + } + constructor(client) { + super(client, false); + } + /** + * Fetch information about Hypixel games + */ + async fetchGameInformation() { + return this.makeGetRequest("/resources/games"); + } + /** + * Fetch all achievements + */ + async fetchAchievements() { + return this.makeGetRequest("/resources/achievements"); + } + /** + * Fetch all challenges + */ + async fetchChallenges() { + return this.makeGetRequest("/resources/challenges"); + } + /** + * Fetch all quests + */ + async fetchQuests() { + return this.makeGetRequest("/resources/quests"); + } + /** + * Fetch all guild achievements + */ + async fetchGuildAchievements() { + return this.makeGetRequest("/resources/guilds/achievements"); + } + /** + * Fetch all vanity pets + */ + async fetchVanityPets() { + return this.makeGetRequest("/resources/vanity/pets"); + } + /** + * Fetch all vanity companions + */ + async fetchVanityCompanions() { + return this.makeGetRequest("/resources/vanity/companions"); + } +}; + +// src/lib/managers/SkyBlockManager.ts +var SkyBlockManager = class extends BaseManager { + static { + __name(this, "SkyBlockManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch information regarding collections in the SkyBlock game + */ + async fetchCollections() { + const data = await this.makeGetRequest("/resources/skyblock/collections"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections + }; + } + /** + * Fetch information regarding skills in the SkyBlock game + */ + async fetchSkills() { + const data = await this.makeGetRequest("/resources/skyblock/skills"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections, + skills: data.skills + }; + } + /** + * Fetch information regarding items in the SkyBlock game + */ + async fetchItems() { + const data = await this.makeGetRequest("/resources/skyblock/items"); + return { + lastUpdated: data.lastUpdated, + items: data.items + }; + } + /** + * Fetch information regarding the current mayor and ongoing election in SkyBlock + */ + async fetchElectionAndMayor() { + const data = await this.makeGetRequest("/resources/skyblock/election"); + return { + lastUpdated: data.lastUpdated, + mayor: data.mayor, + current: data.current + }; + } + /** + * Fetch information regarding the current bingo event and its goals + */ + async fetchActiveBingoGoals() { + const data = await this.makeGetRequest("/resources/skyblock/bingo"); + return { + lastUpdated: data.lastUpdated, + id: data.id, + goals: data.goals + }; + } + /** + * Fetch SkyBlock news + */ + async fetchNews() { + const data = await this.makeGetRequest("/skyblock/news"); + return { + items: data.items + }; + } + /** + * Fetch a SkyBlock auction. + * @param identifier The idenitifer you're using to fetch the auction + * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`) + * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`. + */ + async fetchAuction(identifier, type, raw = false) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "type"); + if (type !== "uuid" && type !== "player" && type !== "profile") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchAuction", "type", ["uuid", "player", "profile"]); + const { auctions } = await this.makeGetRequest(`/skyblock/auction?${type}=${identifier}`); + if (!raw) { + const parsed = []; + for (const auction of auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return parsed; + } + return auctions; + } + /** + * Fetch the currently active auctions (sorted by last updated first and paginated) + * @param page The page number + * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`. + */ + async fetchActiveAuctions(page, resolveAuctions = true) { + if (page && typeof page !== "number") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchActiveAuctions", "page", ["number"]); + const data = await this.makeGetRequest(`/skyblock/auctions${page ? "?page=" + page : ""}`); + if (resolveAuctions) { + const parsed = []; + for (const auction of data.auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: parsed + }; + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: data.auctions + }; + } + /** + * Fetch recently ended auctions (auctions which ended in the last 60 seconds). + */ + async fetchRecentlyEndedAuctions() { + const data = await this.makeGetRequest("/skyblock/auctions_ended"); + return { + lastUpdated: data.lastUpdated, + auctions: data.auctions + }; + } + /** + * Fetch bazaar items + */ + async fetchBazaar() { + const data = await this.makeGetRequest("/skyblock/bazaar"); + return { + lastUpdated: data.lastUpdated, + products: data.products + }; + } + /** + * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchProfile(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchProfile", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`); + return new SkyBlockProfile(this.client, data); + } + /** + * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchMuseum(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchMuseum", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`); + return new SkyBlockMuseum(this.client, data); + } + /** + * Fetch a SkyBlock profiles of a player + * @param playerUuid The uuid of the player + */ + async fetchPlayerSkyBlockProfiles(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchPlayerSkyBlockProfiles", "playerUuid"); + const { profiles } = await this.makeGetRequest(`/skyblock/profiles?uuid=${playerUuid}`); + const parsed = []; + for (const profile of profiles) { + parsed.push(new SkyBlockProfile(this.client, profile)); + } + return parsed; + } + /** + * Fetch bingo data of a player + * @param playerUuid The uuid of the player + */ + async fetchBingoData(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchBingoData", "playerUuid"); + const data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`); + return { + events: data.events + }; + } + /** + * Fetch the currently active or upcoming Fire Sales for SkyBlock + */ + async fetchFireSales() { + const { sales } = await this.makeGetRequest("/skyblock/firesales"); + return sales; + } +}; + +// src/lib/rest/ApiRequest.ts +var ApiRequest = class { + static { + __name(this, "ApiRequest"); + } + /** + * The request manager instance + */ + requests; + /** + * The options of this request + */ + options; + constructor(requestManager, options) { + this.requests = requestManager; + this.options = options; + } + /** + * Makes a request with the options provided. + */ + async make() { + const options = this.buildOptions(); + const res = await fetch(options.url, { + ...options + }); + if (!res.ok) { + const error = await res.json(); + throw new HypixelAPIError(error?.cause ?? res.statusText, res.status); + } + return res; + } + /** + * Creates an object containing the options to be passed to the request + */ + buildOptions() { + const apiKey = this.requests.client.options?.apiKey; + const headers = { + "Content-Type": "application/json" + }; + if (this.options.sendAPIKey) { + if (!apiKey) + throw new HypixelTSError("CLIENT_OPTIONS_MISSING", "apiKey"); + headers["API-Key"] = apiKey; + } + const options = { + url: `${this.requests.baseApiUrl}${this.options.path}`, + method: this.options.method ?? "GET", + headers + }; + return options; + } +}; + +// src/lib/rest/HypixelAPIError.ts +var HypixelAPIError = class extends Error { + static { + __name(this, "HypixelAPIError"); + } + code; + constructor(message, code) { + super(message); + this.message = message; + this.code = code; + } +}; + +// src/lib/rest/RequestManager.ts +var import_async_queue = require("@sapphire/async-queue"); +var RequestManager2 = class { + static { + __name(this, "RequestManager"); + } + /** + * The hypixel.ts client instance + */ + client; + /** + * The base url of the hypixel API + */ + baseApiUrl; + /** + * Queue for requests + * @see {@link https://npmjs.com/@sapphire/async-queue} + */ + queue; + constructor(client) { + this.client = client; + this.baseApiUrl = client.options?.baseApiUrl ?? "https://api.hypixel.net"; + this.queue = new import_async_queue.AsyncQueue(); + } + /** + * Makes the api request and pushes it to the request queue + * @param path The path/endpoint to make the request to + * @param sendAPIKey Whether or not to send the apiKey with this request + */ + async execute(path, sendAPIKey) { + await this.queue.wait(); + try { + const request = await new ApiRequest(this, { path, sendAPIKey }).make(); + return request.json(); + } finally { + this.queue.shift(); + } + } +}; + +// src/lib/Client.ts +var Client = class { + static { + __name(this, "Client"); + } + options; + requests; + players; + guilds; + resources; + others; + skyblock; + constructor(options) { + this.options = options ?? {}; + this.options.baseApiUrl = "https://api.hypixel.net"; + } + /** + * Starts the hypixel client (registers all managers) + * *NOTE*: This method must be called before further usage. + */ + start() { + this.registerManagers(); + return this; + } + /** + * Register all the managers + */ + registerManagers() { + this.requests = new RequestManager2(this); + this.players = new PlayerManager(this); + this.guilds = new GuildManager(this); + this.resources = new ResourceManager(this); + this.others = new OtherManager(this); + this.skyblock = new SkyBlockManager(this); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + Client +}); +//# sourceMappingURL=Client.js.map \ No newline at end of file diff --git a/dist/cjs/lib/Client.js.map b/dist/cjs/lib/Client.js.map new file mode 100644 index 0000000..9bf987b --- /dev/null +++ b/dist/cjs/lib/Client.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/lib/Client.ts","../../../src/lib/managers/BaseManager.ts","../../../src/lib/errors/HypixelTSError.ts","../../../src/lib/classes/Base.ts","../../../src/lib/classes/Guild.ts","../../../src/lib/managers/GuildManager.ts","../../../src/lib/managers/OtherManager.ts","../../../src/lib/classes/Player.ts","../../../src/lib/classes/SkyBlockAuction.ts","../../../src/lib/classes/SkyBlockProfile.ts","../../../src/lib/classes/SkyBlockMuseum.ts","../../../src/lib/classes/Util.ts","../../../src/lib/errors/Messages.ts","../../../src/lib/managers/PlayerManager.ts","../../../src/lib/managers/ResourceManager.ts","../../../src/lib/managers/SkyBlockManager.ts","../../../src/lib/rest/ApiRequest.ts","../../../src/lib/rest/HypixelAPIError.ts","../../../src/lib/rest/RequestManager.ts"],"sourcesContent":["import { PlayerManager, GuildManager, ResourceManager, OtherManager, SkyBlockManager } from './managers/index';\r\nimport { RequestManager } from './rest/index';\r\nimport type { ClientOptions } from '../index';\r\n\r\n/**\r\n * The hypixel.ts client.\r\n * @category Classes\r\n */\r\nexport class Client {\r\n\tpublic options?: ClientOptions;\r\n\tpublic requests!: RequestManager;\r\n\tpublic players!: PlayerManager;\r\n\tpublic guilds!: GuildManager;\r\n\tpublic resources!: ResourceManager;\r\n\tpublic others!: OtherManager;\r\n\tpublic skyblock!: SkyBlockManager;\r\n\r\n\tpublic constructor(options?: ClientOptions) {\r\n\t\tthis.options = options ?? {};\r\n\t\tthis.options.baseApiUrl = 'https://api.hypixel.net';\r\n\t}\r\n\r\n\t/**\r\n\t * Starts the hypixel client (registers all managers)\r\n\t * *NOTE*: This method must be called before further usage.\r\n\t */\r\n\tpublic start() {\r\n\t\tthis.registerManagers();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Register all the managers\r\n\t */\r\n\tprivate registerManagers() {\r\n\t\tthis.requests = new RequestManager(this);\r\n\t\tthis.players = new PlayerManager(this);\r\n\t\tthis.guilds = new GuildManager(this);\r\n\t\tthis.resources = new ResourceManager(this);\r\n\t\tthis.others = new OtherManager(this);\r\n\t\tthis.skyblock = new SkyBlockManager(this);\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APIGuild } from '../typings';\r\n\r\n/**\r\n * The guild class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get}\r\n */\r\nexport class Guild extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Guild data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIGuild) {\r\n\t\tsuper(client);\r\n\t\tdata.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport { Guild } from '../classes/Guild';\r\nimport type { APIGuild } from '../typings';\r\nimport type { Client } from '../Client';\r\n\r\n/**\r\n * Guild related endpoints\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class GuildManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid\r\n\t * @param identifier The id/name of the guild or the uuid of the player\r\n\t * @param type The type of identifier you're passing (id/name of guild, player uuid)\r\n\t */\r\n\tpublic async fetch(identifier: string, type: 'id' | 'name' | 'player') {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'type');\r\n\t\tif (type !== 'id' && type !== 'name' && type !== 'player')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'GuildManager', 'fetch', 'type', ['id', 'name', 'player']);\r\n\r\n\t\tconst { guild } = await this.makeGetRequest<{ guild: APIGuild | null }>(`/guild?${type}=${identifier}`);\r\n\t\treturn guild ? new Guild(this.client, guild) : null;\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport type {\r\n\tActiveNetworkBoostersResponse,\r\n\tCurrentPlayerCountsResponse,\r\n\tCurrentLeaderboardsResponse,\r\n\tPunishmentStatisticsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Other endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/Other}\r\n */\r\nexport class OtherManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all active network boosters\r\n\t */\r\n\tpublic async fetchActiveNetworkBoosters(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/boosters');\r\n\t\treturn {\r\n\t\t\tboosters: data.boosters,\r\n\t\t\tboosterState: data.boosterState\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current player counts across all games\r\n\t */\r\n\tpublic async fetchCurrentPlayerCounts(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/counts');\r\n\t\treturn {\r\n\t\t\tplayerCount: data.playerCount,\r\n\t\t\tgames: data.games\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current leaderboards\r\n\t */\r\n\tpublic async fetchCurrentLeaderboards(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/leaderboards');\r\n\t\treturn {\r\n\t\t\tleaderboards: data.leaderboards\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch punishment statistics\r\n\t */\r\n\tpublic async fetchPunishmentStatistics(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/punishmentstats');\r\n\t\treturn {\r\n\t\t\twatchdog_lastMinute: data.watchdog_lastMinute,\r\n\t\t\tstaff_rollingDaily: data.staff_rollingDaily,\r\n\t\t\twatchdog_total: data.watchdog_total,\r\n\t\t\twatchdog_rollingDaily: data.watchdog_rollingDaily,\r\n\t\t\tstaff_total: data.staff_total\r\n\t\t};\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { Client } from '../Client';\r\nimport { APIPlayer } from '../typings';\r\n\r\nexport interface Player extends APIPlayer {}\r\n/**\r\n * The player class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get}\r\n */\r\nexport class Player extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Player data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIPlayer) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the SkyBlock profiles of this player\r\n\t * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles}\r\n\t */\r\n\tpublic async fetchSkyBlockProfiles() {\r\n\t\treturn this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockAuction } from '../typings';\r\n\r\nexport interface SkyBlockAuction extends APISkyBlockAuction {}\r\n/**\r\n * The sky block auction class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get}\r\n */\r\nexport class SkyBlockAuction extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock auction data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockAuction) {\r\n\t\tsuper(client);\r\n\t\tif ('_id' in data) data.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockProfile } from '../typings';\r\n\r\nexport interface SkyBlockProfile extends APISkyBlockProfile {}\r\n/**\r\n * The SkyBlockProfile class.\r\n * @category Classes\r\n * @Group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get}\r\n */\r\nexport class SkyBlockProfile extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockProfile) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockMuseum } from '../typings';\r\n\r\nexport interface SkyBlockMuseum extends APISkyBlockMuseum {}\r\n/**\r\n * The SkyBlockMuseum class.\r\n * @category Classes\r\n * @Group Classes\r\n */\r\nexport class SkyBlockMuseum extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockMuseum) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport type { GetUsernameResponse, GetUUIDResponse } from '../typings';\r\n\r\n/**\r\n * Utility functions\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Util extends Base {\r\n\t/**\r\n\t * Get the UUID of a player by providing their name\r\n\t * @param name The name of the player\r\n\t */\r\n\tpublic static async getUUID(name: string): Promise {\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`);\r\n\t\t\tconst json = (await data.json()) as GetUUIDResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_UUID_ERROR', json.errorMessage, data.status);\r\n\t\t\treturn json.id;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_UUID_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Get player's name from their UUID\r\n\t * @param uuid The uuid of the player\r\n\t */\r\n\tpublic static async getUsername(uuid: string): Promise {\r\n\t\tif (!this.isUUID(uuid)) {\r\n\t\t\tthrow new HypixelTSError('NOT_UUID');\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/user/profile/${uuid}`);\r\n\t\t\tconst json = (await data.json()) as GetUsernameResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_USERNAME_ERROR', json.errorMessage, data.status);\r\n\r\n\t\t\treturn json.name;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_USERNAME_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Check whether the provided UUID is a valid UUID or not\r\n\t * @param uuid The UUID to check\r\n\t */\r\n\tpublic static isUUID(uuid: string) {\r\n\t\tconst regexStripped = /^[0-9a-f]{32}$/i;\r\n\t\tconst regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}$/i;\r\n\t\treturn regexStripped.test(uuid) || regexFull.test(uuid);\r\n\t}\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n","import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport { Player, Util } from '../classes/index';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport type { APIPlayer, GetRecentlyPlayedGamesResponse, GetStatusResponse } from '../typings';\r\n\r\n/**\r\n * Player related endpoints.\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class PlayerManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a player using their username or uuid\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async fetch(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'fetch', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { player } = await this.makeGetRequest<{ player: APIPlayer }>(`/player?uuid=${uuid}`);\r\n\t\treturn new Player(this.client, player);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the recently played games of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getRecentlyPlayedGames(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getRecentlyPlayedGames', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { games } = await this.makeGetRequest<{ games: GetRecentlyPlayedGamesResponse[] }>(`/recentgames?uuid=${uuid}`);\r\n\t\treturn games;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the status of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getStatus(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getStatus', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { session } = await this.makeGetRequest<{ session: GetStatusResponse }>(`/status?uuid=${uuid}`);\r\n\t\treturn session;\r\n\t}\r\n\r\n\t/**\r\n\t * Resolves the username to a uuid for use in requests\r\n\t * @param identifier The username (or uuid) of the player\r\n\t */\r\n\tprivate async getUUID(identifier: string) {\r\n\t\tconst isUUID = Util.isUUID(identifier);\r\n\r\n\t\tif (!isUUID) {\r\n\t\t\tconst uuid = await Util.getUUID(identifier);\r\n\t\t\treturn uuid;\r\n\t\t}\r\n\r\n\t\treturn identifier;\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport type { Client } from '../Client';\r\nimport type {\r\n\tVanityPetsResponse,\r\n\tAchievementsResponse,\r\n\tChallengesResponse,\r\n\tGameInformationResponse,\r\n\tGuildAchievementsResponse,\r\n\tQuestsResponse,\r\n\tVanityCompanionsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Resource endpoints.\r\n *\r\n * **Note**: API Key authorization is not required to use this manager.\r\n *\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class ResourceManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, false);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information about Hypixel games\r\n\t */\r\n\tpublic async fetchGameInformation() {\r\n\t\treturn this.makeGetRequest('/resources/games');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all achievements\r\n\t */\r\n\tpublic async fetchAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all challenges\r\n\t */\r\n\tpublic async fetchChallenges() {\r\n\t\treturn this.makeGetRequest('/resources/challenges');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all quests\r\n\t */\r\n\tpublic async fetchQuests() {\r\n\t\treturn this.makeGetRequest('/resources/quests');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all guild achievements\r\n\t */\r\n\tpublic async fetchGuildAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/guilds/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity pets\r\n\t */\r\n\tpublic async fetchVanityPets() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/pets');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity companions\r\n\t */\r\n\tpublic async fetchVanityCompanions() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/companions');\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport { SkyBlockProfile, SkyBlockAuction, SkyBlockMuseum } from '../classes/index';\r\nimport type { Client } from '../Client';\r\nimport {\r\n\ttype APISkyBlockProfile,\r\n\ttype FetchCollectionsResponse,\r\n\ttype FetchSkillsResponse,\r\n\ttype FetchItemsResponse,\r\n\ttype FetchElectionAndMayorResponse,\r\n\ttype FetchActiveBingoGoalsResponse,\r\n\ttype FetchNewsResponse,\r\n\ttype APISkyBlockAuction,\r\n\ttype FetchActiveAuctionsResponse,\r\n\ttype FetchBazaarResponse,\r\n\ttype RecentlyEndedAuctionsResponse,\r\n\ttype FetchBingoDataResponse,\r\n\ttype FetchFireSalesResponse,\r\n\ttype FetchFireSalesResponseFireSale,\r\n\tAPISkyBlockMuseum\r\n} from '../typings';\r\n\r\n/**\r\n * Skyblock related endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock}\r\n */\r\nexport class SkyBlockManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding collections in the SkyBlock game\r\n\t */\r\n\tpublic async fetchCollections(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/collections');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding skills in the SkyBlock game\r\n\t */\r\n\tpublic async fetchSkills(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/skills');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections,\r\n\t\t\tskills: data.skills\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding items in the SkyBlock game\r\n\t */\r\n\tpublic async fetchItems(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/items');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current mayor and ongoing election in SkyBlock\r\n\t */\r\n\tpublic async fetchElectionAndMayor(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/election');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tmayor: data.mayor,\r\n\t\t\tcurrent: data.current\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current bingo event and its goals\r\n\t */\r\n\tpublic async fetchActiveBingoGoals(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/bingo');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tid: data.id,\r\n\t\t\tgoals: data.goals\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch SkyBlock news\r\n\t */\r\n\tpublic async fetchNews() {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/news');\r\n\t\treturn {\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock auction.\r\n\t * @param identifier The idenitifer you're using to fetch the auction\r\n\t * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`)\r\n\t * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`.\r\n\t */\r\n\tpublic async fetchAuction(\r\n\t\tidentifier: string,\r\n\t\ttype: 'uuid' | 'player' | 'profile',\r\n\t\traw = false\r\n\t): Promise {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'type');\r\n\t\tif (type !== 'uuid' && type !== 'player' && type !== 'profile')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchAuction', 'type', ['uuid', 'player', 'profile']);\r\n\r\n\t\tconst { auctions } = await this.makeGetRequest<{ auctions: APISkyBlockAuction[] }>(`/skyblock/auction?${type}=${identifier}`);\r\n\r\n\t\tif (!raw) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn parsed;\r\n\t\t}\r\n\r\n\t\treturn auctions;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active auctions (sorted by last updated first and paginated)\r\n\t * @param page The page number\r\n\t * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`.\r\n\t */\r\n\tpublic async fetchActiveAuctions(page?: number, resolveAuctions = true) {\r\n\t\tif (page && typeof page !== 'number')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchActiveAuctions', 'page', ['number']);\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/auctions${page ? '?page=' + page : ''}`);\r\n\r\n\t\tif (resolveAuctions) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of data.auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn {\r\n\t\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\t\tpage: data.page,\r\n\t\t\t\ttotalPages: data.totalPages,\r\n\t\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\t\tauctions: parsed\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tpage: data.page,\r\n\t\t\ttotalPages: data.totalPages,\r\n\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch recently ended auctions (auctions which ended in the last 60 seconds).\r\n\t */\r\n\tpublic async fetchRecentlyEndedAuctions(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/auctions_ended');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bazaar items\r\n\t */\r\n\tpublic async fetchBazaar(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/bazaar');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tproducts: data.products\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchProfile(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchProfile', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockProfile(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchMuseum(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchMuseum', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockMuseum(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profiles of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchPlayerSkyBlockProfiles(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchPlayerSkyBlockProfiles', 'playerUuid');\r\n\r\n\t\tconst { profiles } = await this.makeGetRequest<{ profiles: APISkyBlockProfile[] }>(`/skyblock/profiles?uuid=${playerUuid}`);\r\n\t\tconst parsed = [];\r\n\r\n\t\tfor (const profile of profiles) {\r\n\t\t\tparsed.push(new SkyBlockProfile(this.client, profile));\r\n\t\t}\r\n\r\n\t\treturn parsed;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bingo data of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchBingoData(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchBingoData', 'playerUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`);\r\n\t\treturn {\r\n\t\t\tevents: data.events\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active or upcoming Fire Sales for SkyBlock\r\n\t */\r\n\tpublic async fetchFireSales(): Promise {\r\n\t\tconst { sales } = await this.makeGetRequest('/skyblock/firesales');\r\n\t\treturn sales;\r\n\t}\r\n}\r\n","import { RequestManager, HypixelAPIError, type HypixelAPIErrorResponse } from './index';\r\nimport { HypixelTSError } from '../errors/index';\r\n\r\n/**\r\n * The options supplied to the request\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface ApiRequestOptions {\r\n\t/**\r\n\t * The request path/endpoint\r\n\t */\r\n\tpath: string;\r\n\r\n\t/**\r\n\t * The request method, only `GET` is supported\r\n\t */\r\n\tmethod?: 'GET';\r\n\r\n\t/**\r\n\t * Whether to send the API key for this request\r\n\t */\r\n\tsendAPIKey?: boolean;\r\n}\r\n\r\n/**\r\n * Handles (sending/building options) requests\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class ApiRequest {\r\n\t/**\r\n\t * The request manager instance\r\n\t */\r\n\tpublic requests: RequestManager;\r\n\r\n\t/**\r\n\t * The options of this request\r\n\t */\r\n\tpublic options: ApiRequestOptions;\r\n\r\n\tpublic constructor(requestManager: RequestManager, options: ApiRequestOptions) {\r\n\t\tthis.requests = requestManager;\r\n\t\tthis.options = options;\r\n\t}\r\n\r\n\t/**\r\n\t * Makes a request with the options provided.\r\n\t */\r\n\tpublic async make() {\r\n\t\tconst options = this.buildOptions();\r\n\r\n\t\tconst res = await fetch(options.url, {\r\n\t\t\t...options\r\n\t\t});\r\n\r\n\t\tif (!res.ok) {\r\n\t\t\tconst error = (await res.json()) as HypixelAPIErrorResponse;\r\n\t\t\tthrow new HypixelAPIError(error?.cause ?? res.statusText, res.status);\r\n\t\t}\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an object containing the options to be passed to the request\r\n\t */\r\n\tpublic buildOptions() {\r\n\t\tconst apiKey = this.requests.client.options?.apiKey;\r\n\r\n\t\tconst headers: Record = {\r\n\t\t\t'Content-Type': 'application/json'\r\n\t\t};\r\n\r\n\t\tif (this.options.sendAPIKey) {\r\n\t\t\tif (!apiKey) throw new HypixelTSError('CLIENT_OPTIONS_MISSING', 'apiKey');\r\n\t\t\theaders['API-Key'] = apiKey;\r\n\t\t}\r\n\r\n\t\tconst options = {\r\n\t\t\turl: `${this.requests.baseApiUrl}${this.options.path}`,\r\n\t\t\tmethod: this.options.method ?? 'GET',\r\n\t\t\theaders\r\n\t\t};\r\n\r\n\t\treturn options;\r\n\t}\r\n}\r\n","/**\r\n * Response body when an error is returned by the hypixel api\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface HypixelAPIErrorResponse {\r\n\t/**\r\n\t * Whether or not the request is successful\r\n\t */\r\n\tsuccess: boolean;\r\n\r\n\t/**\r\n\t * The message explaining the error\r\n\t */\r\n\tcause: string;\r\n}\r\n\r\n/**\r\n * Error thrown when an error is encountered while querying the hypixel API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class HypixelAPIError extends Error {\r\n\tpublic code: number;\r\n\r\n\tpublic constructor(message: string, code: number) {\r\n\t\tsuper(message);\r\n\t\tthis.message = message;\r\n\t\tthis.code = code;\r\n\t}\r\n}\r\n","import { AsyncQueue } from '@sapphire/async-queue';\r\nimport { ApiRequest } from './ApiRequest';\r\nimport { Client } from '../Client';\r\n\r\n/**\r\n * Manages the requests to the API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class RequestManager {\r\n\t/**\r\n\t * The hypixel.ts client instance\r\n\t */\r\n\tpublic client: Client;\r\n\r\n\t/**\r\n\t * The base url of the hypixel API\r\n\t */\r\n\tpublic baseApiUrl: string;\r\n\r\n\t/**\r\n\t * Queue for requests\r\n\t * @see {@link https://npmjs.com/@sapphire/async-queue}\r\n\t */\r\n\tprivate queue: AsyncQueue;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t\tthis.baseApiUrl = client.options?.baseApiUrl ?? 'https://api.hypixel.net';\r\n\t\tthis.queue = new AsyncQueue();\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the api request and pushes it to the request queue\r\n\t * @param path The path/endpoint to make the request to\r\n\t * @param sendAPIKey Whether or not to send the apiKey with this request\r\n\t */\r\n\tpublic async execute(path: string, sendAPIKey: boolean) {\r\n\t\tawait this.queue.wait();\r\n\t\ttry {\r\n\t\t\tconst request = await new ApiRequest(this, { path, sendAPIKey }).make();\r\n\t\t\treturn request.json() as T;\r\n\t\t} finally {\r\n\t\t\tthis.queue.shift();\r\n\t\t}\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,cAAN,MAAkB;AAAA,EAPzB,OAOyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAId;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEH,YAAY,QAAgB,cAAuB;AACzD,SAAK,SAAS;AACd,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAgB,eAAkB,MAAc;AAC/C,WAAO,KAAK,OAAO,SAAS,QAAW,MAAM,KAAK,YAAY;AAAA,EAC/D;AACD;;;AC/BA,IAAM,WAAW,oBAAI,IA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ACzC;AACD;","names":["key","args","messages","RequestManager","RequestManager"]} \ No newline at end of file diff --git a/dist/cjs/lib/classes/Base.d.ts b/dist/cjs/lib/classes/Base.d.ts new file mode 100644 index 0000000..a526c02 --- /dev/null +++ b/dist/cjs/lib/classes/Base.d.ts @@ -0,0 +1,2 @@ +export { Base } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/classes/Base.js b/dist/cjs/lib/classes/Base.js new file mode 100644 index 0000000..e280655 --- /dev/null +++ b/dist/cjs/lib/classes/Base.js @@ -0,0 +1,43 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/classes/Base.ts +var Base_exports = {}; +__export(Base_exports, { + Base: () => Base +}); +module.exports = __toCommonJS(Base_exports); +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + Base +}); +//# sourceMappingURL=Base.js.map \ No newline at end of file diff --git a/dist/cjs/lib/classes/Base.js.map b/dist/cjs/lib/classes/Base.js.map new file mode 100644 index 0000000..ff8f4f4 --- /dev/null +++ b/dist/cjs/lib/classes/Base.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/Base.ts"],"sourcesContent":["import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,IAAM,OAAN,MAAW;AAAA,EAPlB,OAOkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA,EAEH,YAAY,QAAgB;AAClC,SAAK,SAAS;AAAA,EACf;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/classes/Guild.d.ts b/dist/cjs/lib/classes/Guild.d.ts new file mode 100644 index 0000000..c73951a --- /dev/null +++ b/dist/cjs/lib/classes/Guild.d.ts @@ -0,0 +1,2 @@ +export { Guild } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/classes/Guild.js b/dist/cjs/lib/classes/Guild.js new file mode 100644 index 0000000..4a07b64 --- /dev/null +++ b/dist/cjs/lib/classes/Guild.js @@ -0,0 +1,61 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/classes/Guild.ts +var Guild_exports = {}; +__export(Guild_exports, { + Guild: () => Guild +}); +module.exports = __toCommonJS(Guild_exports); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/Guild.ts +var Guild = class extends Base { + static { + __name(this, "Guild"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client, data) { + super(client); + data.id = data._id; + Object.assign(this, data); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + Guild +}); +//# sourceMappingURL=Guild.js.map \ No newline at end of file diff --git a/dist/cjs/lib/classes/Guild.js.map b/dist/cjs/lib/classes/Guild.js.map new file mode 100644 index 0000000..cb41c65 --- /dev/null +++ b/dist/cjs/lib/classes/Guild.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/Guild.ts","../../../../src/lib/classes/Base.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APIGuild } from '../typings';\r\n\r\n/**\r\n * The guild class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get}\r\n */\r\nexport class Guild extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Guild data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIGuild) {\r\n\t\tsuper(client);\r\n\t\tdata.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,OAAN,MAAW;AAAA,EAPlB,OAOkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA,EAEH,YAAY,QAAgB;AAClC,SAAK,SAAS;AAAA,EACf;AACD;;;ADNO,IAAM,QAAN,cAAoB,KAAK;AAAA,EAVhC,OAUgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,YAAY,QAAgB,MAAgB;AAClD,UAAM,MAAM;AACZ,SAAK,KAAK,KAAK;AACf,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/classes/Player.d.ts b/dist/cjs/lib/classes/Player.d.ts new file mode 100644 index 0000000..a0de600 --- /dev/null +++ b/dist/cjs/lib/classes/Player.d.ts @@ -0,0 +1,2 @@ +export { Player } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/classes/Player.js b/dist/cjs/lib/classes/Player.js new file mode 100644 index 0000000..2a0461d --- /dev/null +++ b/dist/cjs/lib/classes/Player.js @@ -0,0 +1,67 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/classes/Player.ts +var Player_exports = {}; +__export(Player_exports, { + Player: () => Player +}); +module.exports = __toCommonJS(Player_exports); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/Player.ts +var Player = class extends Base { + static { + __name(this, "Player"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + async fetchSkyBlockProfiles() { + return this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + Player +}); +//# sourceMappingURL=Player.js.map \ No newline at end of file diff --git a/dist/cjs/lib/classes/Player.js.map b/dist/cjs/lib/classes/Player.js.map new file mode 100644 index 0000000..b29eeca --- /dev/null +++ b/dist/cjs/lib/classes/Player.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/Player.ts","../../../../src/lib/classes/Base.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport { Client } from '../Client';\r\nimport { APIPlayer } from '../typings';\r\n\r\nexport interface Player extends APIPlayer {}\r\n/**\r\n * The player class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get}\r\n */\r\nexport class Player extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Player data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIPlayer) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the SkyBlock profiles of this player\r\n\t * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles}\r\n\t */\r\n\tpublic async fetchSkyBlockProfiles() {\r\n\t\treturn this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid);\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,OAAN,MAAW;AAAA,EAPlB,OAOkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA,EAEH,YAAY,QAAgB;AAClC,SAAK,SAAS;AAAA,EACf;AACD;;;ADLO,IAAM,SAAN,cAAqB,KAAK;AAAA,EAXjC,OAWiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,YAAY,QAAgB,MAAiB;AACnD,UAAM,MAAM;AACZ,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,wBAAwB;AACpC,WAAO,KAAK,OAAO,SAAS,4BAA4B,KAAK,IAAI;AAAA,EAClE;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/classes/SkyBlockAuction.d.ts b/dist/cjs/lib/classes/SkyBlockAuction.d.ts new file mode 100644 index 0000000..f34b8dd --- /dev/null +++ b/dist/cjs/lib/classes/SkyBlockAuction.d.ts @@ -0,0 +1,2 @@ +export { SkyBlockAuction } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/classes/SkyBlockAuction.js b/dist/cjs/lib/classes/SkyBlockAuction.js new file mode 100644 index 0000000..8381acf --- /dev/null +++ b/dist/cjs/lib/classes/SkyBlockAuction.js @@ -0,0 +1,62 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/classes/SkyBlockAuction.ts +var SkyBlockAuction_exports = {}; +__export(SkyBlockAuction_exports, { + SkyBlockAuction: () => SkyBlockAuction +}); +module.exports = __toCommonJS(SkyBlockAuction_exports); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/SkyBlockAuction.ts +var SkyBlockAuction = class extends Base { + static { + __name(this, "SkyBlockAuction"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client, data) { + super(client); + if ("_id" in data) + data.id = data._id; + Object.assign(this, data); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + SkyBlockAuction +}); +//# sourceMappingURL=SkyBlockAuction.js.map \ No newline at end of file diff --git a/dist/cjs/lib/classes/SkyBlockAuction.js.map b/dist/cjs/lib/classes/SkyBlockAuction.js.map new file mode 100644 index 0000000..39c569c --- /dev/null +++ b/dist/cjs/lib/classes/SkyBlockAuction.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/SkyBlockAuction.ts","../../../../src/lib/classes/Base.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockAuction } from '../typings';\r\n\r\nexport interface SkyBlockAuction extends APISkyBlockAuction {}\r\n/**\r\n * The sky block auction class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get}\r\n */\r\nexport class SkyBlockAuction extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock auction data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockAuction) {\r\n\t\tsuper(client);\r\n\t\tif ('_id' in data) data.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,OAAN,MAAW;AAAA,EAPlB,OAOkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA,EAEH,YAAY,QAAgB;AAClC,SAAK,SAAS;AAAA,EACf;AACD;;;ADLO,IAAM,kBAAN,cAA8B,KAAK;AAAA,EAX1C,OAW0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,YAAY,QAAgB,MAA0B;AAC5D,UAAM,MAAM;AACZ,QAAI,SAAS;AAAM,WAAK,KAAK,KAAK;AAClC,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/classes/SkyBlockMuseum.d.ts b/dist/cjs/lib/classes/SkyBlockMuseum.d.ts new file mode 100644 index 0000000..5def3ed --- /dev/null +++ b/dist/cjs/lib/classes/SkyBlockMuseum.d.ts @@ -0,0 +1,2 @@ +export { SkyBlockMuseum } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/classes/SkyBlockMuseum.js b/dist/cjs/lib/classes/SkyBlockMuseum.js new file mode 100644 index 0000000..78d35a4 --- /dev/null +++ b/dist/cjs/lib/classes/SkyBlockMuseum.js @@ -0,0 +1,60 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/classes/SkyBlockMuseum.ts +var SkyBlockMuseum_exports = {}; +__export(SkyBlockMuseum_exports, { + SkyBlockMuseum: () => SkyBlockMuseum +}); +module.exports = __toCommonJS(SkyBlockMuseum_exports); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/SkyBlockMuseum.ts +var SkyBlockMuseum = class extends Base { + static { + __name(this, "SkyBlockMuseum"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + SkyBlockMuseum +}); +//# sourceMappingURL=SkyBlockMuseum.js.map \ No newline at end of file diff --git a/dist/cjs/lib/classes/SkyBlockMuseum.js.map b/dist/cjs/lib/classes/SkyBlockMuseum.js.map new file mode 100644 index 0000000..242f1ac --- /dev/null +++ b/dist/cjs/lib/classes/SkyBlockMuseum.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/SkyBlockMuseum.ts","../../../../src/lib/classes/Base.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockMuseum } from '../typings';\r\n\r\nexport interface SkyBlockMuseum extends APISkyBlockMuseum {}\r\n/**\r\n * The SkyBlockMuseum class.\r\n * @category Classes\r\n * @Group Classes\r\n */\r\nexport class SkyBlockMuseum extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockMuseum) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,OAAN,MAAW;AAAA,EAPlB,OAOkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA,EAEH,YAAY,QAAgB;AAClC,SAAK,SAAS;AAAA,EACf;AACD;;;ADNO,IAAM,iBAAN,cAA6B,KAAK;AAAA,EAVzC,OAUyC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjC,YAAY,QAAgB,MAAyB;AAC3D,UAAM,MAAM;AACZ,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/classes/SkyBlockProfile.d.ts b/dist/cjs/lib/classes/SkyBlockProfile.d.ts new file mode 100644 index 0000000..7a1f57b --- /dev/null +++ b/dist/cjs/lib/classes/SkyBlockProfile.d.ts @@ -0,0 +1,2 @@ +export { SkyBlockProfile } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/classes/SkyBlockProfile.js b/dist/cjs/lib/classes/SkyBlockProfile.js new file mode 100644 index 0000000..45fcf3c --- /dev/null +++ b/dist/cjs/lib/classes/SkyBlockProfile.js @@ -0,0 +1,60 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/classes/SkyBlockProfile.ts +var SkyBlockProfile_exports = {}; +__export(SkyBlockProfile_exports, { + SkyBlockProfile: () => SkyBlockProfile +}); +module.exports = __toCommonJS(SkyBlockProfile_exports); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/SkyBlockProfile.ts +var SkyBlockProfile = class extends Base { + static { + __name(this, "SkyBlockProfile"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + SkyBlockProfile +}); +//# sourceMappingURL=SkyBlockProfile.js.map \ No newline at end of file diff --git a/dist/cjs/lib/classes/SkyBlockProfile.js.map b/dist/cjs/lib/classes/SkyBlockProfile.js.map new file mode 100644 index 0000000..3ceb53a --- /dev/null +++ b/dist/cjs/lib/classes/SkyBlockProfile.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/SkyBlockProfile.ts","../../../../src/lib/classes/Base.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockProfile } from '../typings';\r\n\r\nexport interface SkyBlockProfile extends APISkyBlockProfile {}\r\n/**\r\n * The SkyBlockProfile class.\r\n * @category Classes\r\n * @Group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get}\r\n */\r\nexport class SkyBlockProfile extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockProfile) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,OAAN,MAAW;AAAA,EAPlB,OAOkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA,EAEH,YAAY,QAAgB;AAClC,SAAK,SAAS;AAAA,EACf;AACD;;;ADLO,IAAM,kBAAN,cAA8B,KAAK;AAAA,EAX1C,OAW0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,YAAY,QAAgB,MAA0B;AAC5D,UAAM,MAAM;AACZ,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/classes/Util.d.ts b/dist/cjs/lib/classes/Util.d.ts new file mode 100644 index 0000000..867c6b6 --- /dev/null +++ b/dist/cjs/lib/classes/Util.d.ts @@ -0,0 +1,2 @@ +export { Util } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/classes/Util.js b/dist/cjs/lib/classes/Util.js new file mode 100644 index 0000000..88522ec --- /dev/null +++ b/dist/cjs/lib/classes/Util.js @@ -0,0 +1,119 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/classes/Util.ts +var Util_exports = {}; +__export(Util_exports, { + Util: () => Util +}); +module.exports = __toCommonJS(Util_exports); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; + +// src/lib/classes/Util.ts +var Util = class extends Base { + static { + __name(this, "Util"); + } + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static async getUUID(name) { + try { + const data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_UUID_ERROR", json.errorMessage, data.status); + return json.id; + } catch { + throw new HypixelTSError("GET_UUID_404"); + } + } + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static async getUsername(uuid) { + if (!this.isUUID(uuid)) { + throw new HypixelTSError("NOT_UUID"); + } + try { + const data = await fetch(`https://api.mojang.com/user/profile/${uuid}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_USERNAME_ERROR", json.errorMessage, data.status); + return json.name; + } catch { + throw new HypixelTSError("GET_USERNAME_404"); + } + } + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid) { + const regexStripped = /^[0-9a-f]{32}$/i; + const regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}$/i; + return regexStripped.test(uuid) || regexFull.test(uuid); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + Util +}); +//# sourceMappingURL=Util.js.map \ No newline at end of file diff --git a/dist/cjs/lib/classes/Util.js.map b/dist/cjs/lib/classes/Util.js.map new file mode 100644 index 0000000..8d5c361 --- /dev/null +++ b/dist/cjs/lib/classes/Util.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/Util.ts","../../../../src/lib/classes/Base.ts","../../../../src/lib/errors/HypixelTSError.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport type { GetUsernameResponse, GetUUIDResponse } from '../typings';\r\n\r\n/**\r\n * Utility functions\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Util extends Base {\r\n\t/**\r\n\t * Get the UUID of a player by providing their name\r\n\t * @param name The name of the player\r\n\t */\r\n\tpublic static async getUUID(name: string): Promise {\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`);\r\n\t\t\tconst json = (await data.json()) as GetUUIDResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_UUID_ERROR', json.errorMessage, data.status);\r\n\t\t\treturn json.id;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_UUID_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Get player's name from their UUID\r\n\t * @param uuid The uuid of the player\r\n\t */\r\n\tpublic static async getUsername(uuid: string): Promise {\r\n\t\tif (!this.isUUID(uuid)) {\r\n\t\t\tthrow new HypixelTSError('NOT_UUID');\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/user/profile/${uuid}`);\r\n\t\t\tconst json = (await data.json()) as GetUsernameResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_USERNAME_ERROR', json.errorMessage, data.status);\r\n\r\n\t\t\treturn json.name;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_USERNAME_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Check whether the provided UUID is a valid UUID or not\r\n\t * @param uuid The UUID to check\r\n\t */\r\n\tpublic static isUUID(uuid: string) {\r\n\t\tconst regexStripped = /^[0-9a-f]{32}$/i;\r\n\t\tconst regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}$/i;\r\n\t\treturn regexStripped.test(uuid) || regexFull.test(uuid);\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,OAAN,MAAW;AAAA,EAPlB,OAOkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA,EAEH,YAAY,QAAgB;AAClC,SAAK,SAAS;AAAA,EACf;AACD;;;ACdA,IAAM,WAAW,oBAAI,IAA2C;AAEzD,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAJ1C,OAI0C;AAAA;AAAA;AAAA,EAClC,YAAY,QAAgB,MAAa;AAC/C,UAAM,WAAW,KAAK,IAAI,CAAC;AAE3B,aAAS,WAAWA,MAAaC,OAAa;AAC7C,UAAI,OAAOD,SAAQ;AAAU,cAAM,IAAI,MAAM,6CAA6C;AAC1F,YAAM,MAAM,SAAS,IAAIA,IAAG;AAE5B,UAAI,CAAC;AAAK,cAAM,IAAI,MAAM,oDA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cjs/lib/classes/index.d.ts new file mode 100644 index 0000000..87577a6 --- /dev/null +++ b/dist/cjs/lib/classes/index.d.ts @@ -0,0 +1,2 @@ +export { Base, Guild, Player, SkyBlockAuction, SkyBlockMuseum, SkyBlockProfile, Util } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/classes/index.js b/dist/cjs/lib/classes/index.js new file mode 100644 index 0000000..387786a --- /dev/null +++ b/dist/cjs/lib/classes/index.js @@ -0,0 +1,216 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/classes/index.ts +var classes_exports = {}; +__export(classes_exports, { + Base: () => Base, + Guild: () => Guild, + Player: () => Player, + SkyBlockAuction: () => SkyBlockAuction, + SkyBlockMuseum: () => SkyBlockMuseum, + SkyBlockProfile: () => SkyBlockProfile, + Util: () => Util +}); +module.exports = __toCommonJS(classes_exports); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/Guild.ts +var Guild = class extends Base { + static { + __name(this, "Guild"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client, data) { + super(client); + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/classes/Player.ts +var Player = class extends Base { + static { + __name(this, "Player"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + async fetchSkyBlockProfiles() { + return this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid); + } +}; + +// src/lib/classes/SkyBlockAuction.ts +var SkyBlockAuction = class extends Base { + static { + __name(this, "SkyBlockAuction"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client, data) { + super(client); + if ("_id" in data) + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockProfile.ts +var SkyBlockProfile = class extends Base { + static { + __name(this, "SkyBlockProfile"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockMuseum.ts +var SkyBlockMuseum = class extends Base { + static { + __name(this, "SkyBlockMuseum"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; + +// src/lib/classes/Util.ts +var Util = class extends Base { + static { + __name(this, "Util"); + } + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static async getUUID(name) { + try { + const data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_UUID_ERROR", json.errorMessage, data.status); + return json.id; + } catch { + throw new HypixelTSError("GET_UUID_404"); + } + } + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static async getUsername(uuid) { + if (!this.isUUID(uuid)) { + throw new HypixelTSError("NOT_UUID"); + } + try { + const data = await fetch(`https://api.mojang.com/user/profile/${uuid}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_USERNAME_ERROR", json.errorMessage, data.status); + return json.name; + } catch { + throw new HypixelTSError("GET_USERNAME_404"); + } + } + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid) { + const regexStripped = /^[0-9a-f]{32}$/i; + const regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}$/i; + return regexStripped.test(uuid) || regexFull.test(uuid); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + Base, + Guild, + Player, + SkyBlockAuction, + SkyBlockMuseum, + SkyBlockProfile, + Util +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/cjs/lib/classes/index.js.map b/dist/cjs/lib/classes/index.js.map new file mode 100644 index 0000000..4819b33 --- /dev/null +++ b/dist/cjs/lib/classes/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/index.ts","../../../../src/lib/classes/Base.ts","../../../../src/lib/classes/Guild.ts","../../../../src/lib/classes/Player.ts","../../../../src/lib/classes/SkyBlockAuction.ts","../../../../src/lib/classes/SkyBlockProfile.ts","../../../../src/lib/classes/SkyBlockMuseum.ts","../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/classes/Util.ts"],"sourcesContent":["export * from './Base';\r\n\r\nexport * from './Guild';\r\nexport * from './Player';\r\nexport * from './SkyBlockAuction';\r\nexport * from './SkyBlockProfile';\r\nexport * from './SkyBlockMuseum';\r\nexport * from './Util';\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APIGuild } from '../typings';\r\n\r\n/**\r\n * The guild class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get}\r\n */\r\nexport class Guild extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Guild data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIGuild) {\r\n\t\tsuper(client);\r\n\t\tdata.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { Client } from '../Client';\r\nimport { APIPlayer } from '../typings';\r\n\r\nexport interface Player extends APIPlayer {}\r\n/**\r\n * The player class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get}\r\n */\r\nexport class Player extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Player data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIPlayer) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the SkyBlock profiles of this player\r\n\t * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles}\r\n\t */\r\n\tpublic async fetchSkyBlockProfiles() {\r\n\t\treturn this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockAuction } from '../typings';\r\n\r\nexport interface SkyBlockAuction extends APISkyBlockAuction {}\r\n/**\r\n * The sky block auction class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get}\r\n */\r\nexport class SkyBlockAuction extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock auction data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockAuction) {\r\n\t\tsuper(client);\r\n\t\tif ('_id' in data) data.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockProfile } from '../typings';\r\n\r\nexport interface SkyBlockProfile extends APISkyBlockProfile {}\r\n/**\r\n * The SkyBlockProfile class.\r\n * @category Classes\r\n * @Group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get}\r\n */\r\nexport class SkyBlockProfile extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockProfile) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockMuseum } from '../typings';\r\n\r\nexport interface SkyBlockMuseum extends APISkyBlockMuseum {}\r\n/**\r\n * The SkyBlockMuseum class.\r\n * @category Classes\r\n * @Group Classes\r\n */\r\nexport class SkyBlockMuseum extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockMuseum) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import { Base } from './Base';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport type { GetUsernameResponse, GetUUIDResponse } from '../typings';\r\n\r\n/**\r\n * Utility functions\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Util extends Base {\r\n\t/**\r\n\t * Get the UUID of a player by providing their name\r\n\t * @param name The name of the player\r\n\t */\r\n\tpublic static async getUUID(name: string): Promise {\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`);\r\n\t\t\tconst json = (await data.json()) as GetUUIDResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_UUID_ERROR', json.errorMessage, data.status);\r\n\t\t\treturn json.id;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_UUID_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Get player's name from their UUID\r\n\t * @param uuid The uuid of the player\r\n\t */\r\n\tpublic static async getUsername(uuid: string): Promise {\r\n\t\tif (!this.isUUID(uuid)) {\r\n\t\t\tthrow new HypixelTSError('NOT_UUID');\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/user/profile/${uuid}`);\r\n\t\t\tconst json = (await data.json()) as GetUsernameResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_USERNAME_ERROR', json.errorMessage, data.status);\r\n\r\n\t\t\treturn json.name;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_USERNAME_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Check whether the provided UUID is a valid UUID or not\r\n\t * @param uuid The UUID to check\r\n\t */\r\n\tpublic static isUUID(uuid: string) {\r\n\t\tconst regexStripped = /^[0-9a-f]{32}$/i;\r\n\t\tconst regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}$/i;\r\n\t\treturn regexStripped.test(uuid) || regexFull.test(uuid);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,OAAN,MAAW;AAAA,EAPlB,OAOkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA,EAEH,YAAY,QAAgB;AAClC,SAAK,SAAS;AAAA,EACf;AACD;;;ACNO,IAAM,QAAN,cAAoB,KAAK;AAAA,EAVhC,OAUgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,YAAY,QAAgB,MAAgB;AAClD,UAAM,MAAM;AACZ,SAAK,KAAK,KAAK;AACf,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;;;ACTO,IAAM,SAAN,cAAqB,KAAK;AAAA,EAXjC,OAWiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,YAAY,QAAgB,MAAiB;AACnD,UAAM,MAAM;AACZ,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,wBAAwB;AACpC,WAAO,KAAK,OA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XO,IAAM,OAAN,cAAmB,KAAK;AAAA,EAT/B,OAS+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9B,aAAoB,QAAQ,MAA+B;AAC1D,QAAI;AACH,YAAM,OAAO,MAAM,MAAM,mDAAmD,IAAI,EAAE;AAClF,YAAM,OAAQ,MAAM,KAAK,KAAK;AAE9B,UAAI,KAAK;AAAc,cAAM,IAAI,eAAe,kBAAkB,KAAK,cAAc,KAAK,MAAM;AAChG,aAAO,KAAK;AAAA,IACb,QAAQ;AACP,YAAM,IAAI,eAAe,cAAc;AAAA,IACxC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAoB,YAAY,MAA+B;AAC9D,QAAI,CAAC,KAAK,OAAO,IAAI,GAAG;AACvB,YAAM,IAAI,eAAe,UAAU;AAAA,IACpC;AAEA,QAAI;AACH,YAAM,OAAO,MAAM,MAAM,uCAAuC,IAAI,EAAE;AACtE,YAAM,OAAQ,MAAM,KAAK,KAAK;AAE9B,UAAI,KAAK;AAAc,cAAM,IAAI,eAAe,sBAAsB,KAAK,cAAc,KAAK,MAAM;AAEpG,aAAO,KAAK;AAAA,IACb,QAAQ;AACP,YAAM,IAAI,eAAe,kBAAkB;AAAA,IAC5C;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,OAAO,MAAc;AAClC,UAAM,gBAAgB;AACtB,UAAM,YAAY;AAClB,WAAO,cAAc,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI;AAAA,EACvD;AACD;","names":["key","args"]} \ No newline at end of file diff --git a/dist/cjs/lib/errors/HypixelTSError.d.ts b/dist/cjs/lib/errors/HypixelTSError.d.ts new file mode 100644 index 0000000..ad51c18 --- /dev/null +++ b/dist/cjs/lib/errors/HypixelTSError.d.ts @@ -0,0 +1,6 @@ +declare class HypixelTSError extends Error { + constructor(key: string, ...args: any[]); +} +declare function register(name: string, value: any): void; + +export { HypixelTSError, register }; diff --git a/dist/cjs/lib/errors/HypixelTSError.js b/dist/cjs/lib/errors/HypixelTSError.js new file mode 100644 index 0000000..17d1ff6 --- /dev/null +++ b/dist/cjs/lib/errors/HypixelTSError.js @@ -0,0 +1,60 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/errors/HypixelTSError.ts +var HypixelTSError_exports = {}; +__export(HypixelTSError_exports, { + HypixelTSError: () => HypixelTSError, + register: () => register +}); +module.exports = __toCommonJS(HypixelTSError_exports); +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + HypixelTSError, + register +}); +//# sourceMappingURL=HypixelTSError.js.map \ No newline at end of file diff --git a/dist/cjs/lib/errors/HypixelTSError.js.map b/dist/cjs/lib/errors/HypixelTSError.js.map new file mode 100644 index 0000000..63fd0c2 --- /dev/null +++ b/dist/cjs/lib/errors/HypixelTSError.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/errors/HypixelTSError.ts"],"sourcesContent":["type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,WAAW,oBAAI,IAA2C;AAEzD,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAJ1C,OAI0C;AAAA;AAAA;AAAA,EAClC,YAAY,QAAgB,MAAa;AAC/C,UAAM,WAAW,KAAK,IAAI,CAAC;AAE3B,aAAS,WAAWA,MAAaC,OAAa;AAC7C,UAAI,OAAOD,SAAQ;AAAU,cAAM,IAAI,MAAM,6CAA6C;AAC1F,YAAM,MAAM,SAAS,IAAIA,IAAG;AAE5B,UAAI,CAAC;AAAK,cAAM,IAAI,MAAM,oDAAoDA,IAAG,EAAE;AACnF,UAAI,OAAO,QAAQ;AAAY,eAAO,IAAI,GAAGC,KAAI;AACjD,UAAI,CAACA,MAAK;AAAQ,eAAO;AAEzB,MAAAA,MAAK,QAAQ,GAAG;AAChB,aAAO,OAAO,GAAGA,KAAI;AAAA,IACtB;AAVS;AAAA,EAWV;AACD;AAEO,SAAS,SAAS,MAAc,OAAY;AAClD,WAAS,IAAI,MAAM,OAAO,UAAU,aAAa,QAAQ,OAAO,KAAK,CAAC;AACvE;AAFgB;","names":["key","args"]} \ No newline at end of file diff --git a/dist/cjs/lib/errors/Messages.d.ts b/dist/cjs/lib/errors/Messages.d.ts new file mode 100644 index 0000000..223e65e --- /dev/null +++ b/dist/cjs/lib/errors/Messages.d.ts @@ -0,0 +1,2 @@ + +export { } diff --git a/dist/cjs/lib/errors/Messages.js b/dist/cjs/lib/errors/Messages.js new file mode 100644 index 0000000..4a61a4d --- /dev/null +++ b/dist/cjs/lib/errors/Messages.js @@ -0,0 +1,26 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); +//# sourceMappingURL=Messages.js.map \ No newline at end of file diff --git a/dist/cjs/lib/errors/Messages.js.map b/dist/cjs/lib/errors/Messages.js.map new file mode 100644 index 0000000..af603fe --- /dev/null +++ b/dist/cjs/lib/errors/Messages.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/errors/Messages.ts"],"sourcesContent":["type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n"],"mappings":";;;;;AAEA,IAAM,WAAW,oBAAI,IAA2C;AAoBzD,SAAS,SAAS,MAAc,OAAY;AAClD,WAAS,IAAI,MAAM,OAAO,UAAU,aAAa,QAAQ,OAAO,KAAK,CAAC;AACvE;AAFgB;;;ACpBhB,IAAMA,YAAW;AAAA,EAChB,wBAAwB,CAAC,WAAoB,gBAAgB,SAAS,IAAI,MAAM,KAAK,EAAE,IAAI,SAAS,OAAO,KAAK;AAAA,EAChH,4BAA4B,CAAC,QAAgB,MAAc,aAC1D,gBAAgB,MAAM,+BAA+B,IAAI,gBAAgB,QAAQ;AAAA,EAClF,gBAAgB,CAAC,OAAe,SAAiB,mCAAmC,KAAK,iBAAiB,IAAI;AAAA,EAC9G,cAAc;AAAA,EACd,oBAAoB,CAAC,OAAe,SAAiB,uCAAuC,KAAK,iBAAiB,IAAI;AAAA,EACtH,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,uBAAuB,CAAC,SAAiB,QAAgB,WAAmB,GAAG,OAAO,IAAI,MAAM,sBAAsB,MAAM;AAAA,EAC5H,wBAAwB,CAAC,SAAiB,QAAgB,QAAgB,aACzE,GAAG,OAAO,IAAI,MAAM,8CACnB,UAAU,SAAS,IAAI,UAAU,SAAS,KAAK,IAAI,CAAC,KAAK,SAAS,KAAK,IAAI,CAC5E,cAAc,MAAM;AACtB;AAEA,WAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQA,SAAQ;AAAG,WAAS,KAAK,KAAK;","names":["messages"]} \ No newline at end of file diff --git a/dist/cjs/lib/errors/index.d.ts b/dist/cjs/lib/errors/index.d.ts new file mode 100644 index 0000000..ae373b5 --- /dev/null +++ b/dist/cjs/lib/errors/index.d.ts @@ -0,0 +1 @@ +export { HypixelTSError, register } from './HypixelTSError.js'; diff --git a/dist/cjs/lib/errors/index.js b/dist/cjs/lib/errors/index.js new file mode 100644 index 0000000..6432c2f --- /dev/null +++ b/dist/cjs/lib/errors/index.js @@ -0,0 +1,77 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/errors/index.ts +var errors_exports = {}; +__export(errors_exports, { + HypixelTSError: () => HypixelTSError, + register: () => register +}); +module.exports = __toCommonJS(errors_exports); + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + HypixelTSError, + register +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/cjs/lib/errors/index.js.map b/dist/cjs/lib/errors/index.js.map new file mode 100644 index 0000000..16d5199 --- /dev/null +++ b/dist/cjs/lib/errors/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/errors/index.ts","../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/errors/Messages.ts"],"sourcesContent":["export * from './HypixelTSError';\r\nexport * from './Messages';\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,WAAW,oBAAI,IAA2C;AAEzD,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAJ1C,OAI0C;AAAA;AAAA;AA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AAM;AACtB;AAEA,WAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQA,SAAQ;AAAG,WAAS,KAAK,KAAK;","names":["key","args","messages"]} \ No newline at end of file diff --git a/dist/cjs/lib/index.d.ts b/dist/cjs/lib/index.d.ts new file mode 100644 index 0000000..7f817b5 --- /dev/null +++ b/dist/cjs/lib/index.d.ts @@ -0,0 +1,2 @@ +export { APIGuild, APIGuildMember, APIGuildRank, APIPlayer, APISkyBlockAuction, APISkyBlockAuctionBanking, APISkyBlockAuctionBankingTransaction, APISkyBlockAuctionBid, APISkyBlockMuseum, APISkyBlockMuseumItem, APISkyBlockMuseumItemItem, APISkyBlockMuseumItemObject, APISkyBlockMuseumMember, APISkyBlockProfile, APISkyBlockProfileMembers, AchievementsResponse, AchievementsResponseAchievement, AchievementsResponseAchievementOnetime, AchievementsResponseAchievementTiered, ActiveNetworkBoostersResponse, ActiveNetworkBoostersResponseActiveBooster, ActiveNetworkBoostersResponseQueuedBooster, ApiRequest, ApiRequestOptions, Base, BaseManager, BaseResourceResponse, ChallengesResponse, ChallengesResponseChallenge, Client, CurrentLeaderboardsResponse, CurrentPlayerCountsResponse, FetchActiveAuctionsResponse, FetchActiveBingoGoalsResponse, FetchActiveBingoGoalsResponseGoal, FetchBazaarResponse, FetchBazaarResponseProduct, FetchBazaarResponseProductBuySummary, FetchBazaarResponseProductQuickStatus, FetchBazaarResponseProductSellSummary, FetchBingoDataResponse, FetchBingoDataResponseEvent, FetchCollectionsResponse, FetchCollectionsResponseCollection, FetchElectionAndMayorResponse, FetchElectionAndMayorResponseCurrent, FetchElectionAndMayorResponseElection, FetchElectionAndMayorResponseElectionCandidate, FetchElectionAndMayorResponseMayor, FetchElectionAndMayorResponseMayorPerks, FetchFireSalesResponse, FetchFireSalesResponseFireSale, FetchItemsResponse, FetchItemsResponseItem, FetchNewsResponse, FetchNewsResponseItem, FetchSkillsResponse, FetchSkillsResponseCollection, FetchSkillsResponseSkill, GameInformationResponse, GameInformationResponseGame, GetRecentlyPlayedGamesResponse, GetStatusResponse, GetUUIDResponse, GetUsernameResponse, Guild, GuildAchievementsResponse, GuildManager, OtherManager, Player, PlayerManager, PunishmentStatisticsResponse, QuestsResponse, QuestsResponseQuest, RecentlyEndedAuctionsResponse, RecentlyEndedAuctionsResponseAuction, RequestManager, ResourceManager, SkyBlockAuction, SkyBlockManager, SkyBlockMuseum, SkyBlockProfile, Util, VanityCompanionsResponse, VanityPetsRarity, VanityPetsResponse, VanityPetsResponseRarity, VanityPetsResponseType } from '../index.js'; +export { HypixelAPIError, HypixelAPIErrorResponse } from './rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/index.js b/dist/cjs/lib/index.js new file mode 100644 index 0000000..5c0416f --- /dev/null +++ b/dist/cjs/lib/index.js @@ -0,0 +1,822 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/index.ts +var lib_exports = {}; +__export(lib_exports, { + ApiRequest: () => ApiRequest, + Base: () => Base, + BaseManager: () => BaseManager, + Client: () => Client, + Guild: () => Guild, + GuildManager: () => GuildManager, + HypixelAPIError: () => HypixelAPIError, + OtherManager: () => OtherManager, + Player: () => Player, + PlayerManager: () => PlayerManager, + RequestManager: () => RequestManager2, + ResourceManager: () => ResourceManager, + SkyBlockAuction: () => SkyBlockAuction, + SkyBlockManager: () => SkyBlockManager, + SkyBlockMuseum: () => SkyBlockMuseum, + SkyBlockProfile: () => SkyBlockProfile, + Util: () => Util, + VanityPetsRarity: () => VanityPetsRarity +}); +module.exports = __toCommonJS(lib_exports); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/Guild.ts +var Guild = class extends Base { + static { + __name(this, "Guild"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client, data) { + super(client); + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/managers/GuildManager.ts +var GuildManager = class extends BaseManager { + static { + __name(this, "GuildManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid + * @param identifier The id/name of the guild or the uuid of the player + * @param type The type of identifier you're passing (id/name of guild, player uuid) + */ + async fetch(identifier, type) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "type"); + if (type !== "id" && type !== "name" && type !== "player") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "GuildManager", "fetch", "type", ["id", "name", "player"]); + const { guild } = await this.makeGetRequest(`/guild?${type}=${identifier}`); + return guild ? new Guild(this.client, guild) : null; + } +}; + +// src/lib/managers/OtherManager.ts +var OtherManager = class extends BaseManager { + static { + __name(this, "OtherManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch all active network boosters + */ + async fetchActiveNetworkBoosters() { + const data = await this.makeGetRequest("/boosters"); + return { + boosters: data.boosters, + boosterState: data.boosterState + }; + } + /** + * Fetch current player counts across all games + */ + async fetchCurrentPlayerCounts() { + const data = await this.makeGetRequest("/counts"); + return { + playerCount: data.playerCount, + games: data.games + }; + } + /** + * Fetch current leaderboards + */ + async fetchCurrentLeaderboards() { + const data = await this.makeGetRequest("/leaderboards"); + return { + leaderboards: data.leaderboards + }; + } + /** + * Fetch punishment statistics + */ + async fetchPunishmentStatistics() { + const data = await this.makeGetRequest("/punishmentstats"); + return { + watchdog_lastMinute: data.watchdog_lastMinute, + staff_rollingDaily: data.staff_rollingDaily, + watchdog_total: data.watchdog_total, + watchdog_rollingDaily: data.watchdog_rollingDaily, + staff_total: data.staff_total + }; + } +}; + +// src/lib/classes/Player.ts +var Player = class extends Base { + static { + __name(this, "Player"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + async fetchSkyBlockProfiles() { + return this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid); + } +}; + +// src/lib/classes/SkyBlockAuction.ts +var SkyBlockAuction = class extends Base { + static { + __name(this, "SkyBlockAuction"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client, data) { + super(client); + if ("_id" in data) + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockProfile.ts +var SkyBlockProfile = class extends Base { + static { + __name(this, "SkyBlockProfile"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockMuseum.ts +var SkyBlockMuseum = class extends Base { + static { + __name(this, "SkyBlockMuseum"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/Util.ts +var Util = class extends Base { + static { + __name(this, "Util"); + } + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static async getUUID(name) { + try { + const data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_UUID_ERROR", json.errorMessage, data.status); + return json.id; + } catch { + throw new HypixelTSError("GET_UUID_404"); + } + } + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static async getUsername(uuid) { + if (!this.isUUID(uuid)) { + throw new HypixelTSError("NOT_UUID"); + } + try { + const data = await fetch(`https://api.mojang.com/user/profile/${uuid}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_USERNAME_ERROR", json.errorMessage, data.status); + return json.name; + } catch { + throw new HypixelTSError("GET_USERNAME_404"); + } + } + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid) { + const regexStripped = /^[0-9a-f]{32}$/i; + const regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}$/i; + return regexStripped.test(uuid) || regexFull.test(uuid); + } +}; + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); + +// src/lib/managers/PlayerManager.ts +var PlayerManager = class extends BaseManager { + static { + __name(this, "PlayerManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a player using their username or uuid + * @param identifier The username/uuid of the player + */ + async fetch(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "fetch", "identifier"); + const uuid = await this.getUUID(identifier); + const { player } = await this.makeGetRequest(`/player?uuid=${uuid}`); + return new Player(this.client, player); + } + /** + * Fetch the recently played games of a player + * @param identifier The username/uuid of the player + */ + async getRecentlyPlayedGames(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getRecentlyPlayedGames", "identifier"); + const uuid = await this.getUUID(identifier); + const { games } = await this.makeGetRequest(`/recentgames?uuid=${uuid}`); + return games; + } + /** + * Fetch the status of a player + * @param identifier The username/uuid of the player + */ + async getStatus(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getStatus", "identifier"); + const uuid = await this.getUUID(identifier); + const { session } = await this.makeGetRequest(`/status?uuid=${uuid}`); + return session; + } + /** + * Resolves the username to a uuid for use in requests + * @param identifier The username (or uuid) of the player + */ + async getUUID(identifier) { + const isUUID = Util.isUUID(identifier); + if (!isUUID) { + const uuid = await Util.getUUID(identifier); + return uuid; + } + return identifier; + } +}; + +// src/lib/managers/ResourceManager.ts +var ResourceManager = class extends BaseManager { + static { + __name(this, "ResourceManager"); + } + constructor(client) { + super(client, false); + } + /** + * Fetch information about Hypixel games + */ + async fetchGameInformation() { + return this.makeGetRequest("/resources/games"); + } + /** + * Fetch all achievements + */ + async fetchAchievements() { + return this.makeGetRequest("/resources/achievements"); + } + /** + * Fetch all challenges + */ + async fetchChallenges() { + return this.makeGetRequest("/resources/challenges"); + } + /** + * Fetch all quests + */ + async fetchQuests() { + return this.makeGetRequest("/resources/quests"); + } + /** + * Fetch all guild achievements + */ + async fetchGuildAchievements() { + return this.makeGetRequest("/resources/guilds/achievements"); + } + /** + * Fetch all vanity pets + */ + async fetchVanityPets() { + return this.makeGetRequest("/resources/vanity/pets"); + } + /** + * Fetch all vanity companions + */ + async fetchVanityCompanions() { + return this.makeGetRequest("/resources/vanity/companions"); + } +}; + +// src/lib/managers/SkyBlockManager.ts +var SkyBlockManager = class extends BaseManager { + static { + __name(this, "SkyBlockManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch information regarding collections in the SkyBlock game + */ + async fetchCollections() { + const data = await this.makeGetRequest("/resources/skyblock/collections"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections + }; + } + /** + * Fetch information regarding skills in the SkyBlock game + */ + async fetchSkills() { + const data = await this.makeGetRequest("/resources/skyblock/skills"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections, + skills: data.skills + }; + } + /** + * Fetch information regarding items in the SkyBlock game + */ + async fetchItems() { + const data = await this.makeGetRequest("/resources/skyblock/items"); + return { + lastUpdated: data.lastUpdated, + items: data.items + }; + } + /** + * Fetch information regarding the current mayor and ongoing election in SkyBlock + */ + async fetchElectionAndMayor() { + const data = await this.makeGetRequest("/resources/skyblock/election"); + return { + lastUpdated: data.lastUpdated, + mayor: data.mayor, + current: data.current + }; + } + /** + * Fetch information regarding the current bingo event and its goals + */ + async fetchActiveBingoGoals() { + const data = await this.makeGetRequest("/resources/skyblock/bingo"); + return { + lastUpdated: data.lastUpdated, + id: data.id, + goals: data.goals + }; + } + /** + * Fetch SkyBlock news + */ + async fetchNews() { + const data = await this.makeGetRequest("/skyblock/news"); + return { + items: data.items + }; + } + /** + * Fetch a SkyBlock auction. + * @param identifier The idenitifer you're using to fetch the auction + * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`) + * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`. + */ + async fetchAuction(identifier, type, raw = false) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "type"); + if (type !== "uuid" && type !== "player" && type !== "profile") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchAuction", "type", ["uuid", "player", "profile"]); + const { auctions } = await this.makeGetRequest(`/skyblock/auction?${type}=${identifier}`); + if (!raw) { + const parsed = []; + for (const auction of auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return parsed; + } + return auctions; + } + /** + * Fetch the currently active auctions (sorted by last updated first and paginated) + * @param page The page number + * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`. + */ + async fetchActiveAuctions(page, resolveAuctions = true) { + if (page && typeof page !== "number") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchActiveAuctions", "page", ["number"]); + const data = await this.makeGetRequest(`/skyblock/auctions${page ? "?page=" + page : ""}`); + if (resolveAuctions) { + const parsed = []; + for (const auction of data.auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: parsed + }; + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: data.auctions + }; + } + /** + * Fetch recently ended auctions (auctions which ended in the last 60 seconds). + */ + async fetchRecentlyEndedAuctions() { + const data = await this.makeGetRequest("/skyblock/auctions_ended"); + return { + lastUpdated: data.lastUpdated, + auctions: data.auctions + }; + } + /** + * Fetch bazaar items + */ + async fetchBazaar() { + const data = await this.makeGetRequest("/skyblock/bazaar"); + return { + lastUpdated: data.lastUpdated, + products: data.products + }; + } + /** + * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchProfile(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchProfile", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`); + return new SkyBlockProfile(this.client, data); + } + /** + * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchMuseum(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchMuseum", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`); + return new SkyBlockMuseum(this.client, data); + } + /** + * Fetch a SkyBlock profiles of a player + * @param playerUuid The uuid of the player + */ + async fetchPlayerSkyBlockProfiles(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchPlayerSkyBlockProfiles", "playerUuid"); + const { profiles } = await this.makeGetRequest(`/skyblock/profiles?uuid=${playerUuid}`); + const parsed = []; + for (const profile of profiles) { + parsed.push(new SkyBlockProfile(this.client, profile)); + } + return parsed; + } + /** + * Fetch bingo data of a player + * @param playerUuid The uuid of the player + */ + async fetchBingoData(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchBingoData", "playerUuid"); + const data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`); + return { + events: data.events + }; + } + /** + * Fetch the currently active or upcoming Fire Sales for SkyBlock + */ + async fetchFireSales() { + const { sales } = await this.makeGetRequest("/skyblock/firesales"); + return sales; + } +}; + +// src/lib/rest/ApiRequest.ts +var ApiRequest = class { + static { + __name(this, "ApiRequest"); + } + /** + * The request manager instance + */ + requests; + /** + * The options of this request + */ + options; + constructor(requestManager, options) { + this.requests = requestManager; + this.options = options; + } + /** + * Makes a request with the options provided. + */ + async make() { + const options = this.buildOptions(); + const res = await fetch(options.url, { + ...options + }); + if (!res.ok) { + const error = await res.json(); + throw new HypixelAPIError(error?.cause ?? res.statusText, res.status); + } + return res; + } + /** + * Creates an object containing the options to be passed to the request + */ + buildOptions() { + const apiKey = this.requests.client.options?.apiKey; + const headers = { + "Content-Type": "application/json" + }; + if (this.options.sendAPIKey) { + if (!apiKey) + throw new HypixelTSError("CLIENT_OPTIONS_MISSING", "apiKey"); + headers["API-Key"] = apiKey; + } + const options = { + url: `${this.requests.baseApiUrl}${this.options.path}`, + method: this.options.method ?? "GET", + headers + }; + return options; + } +}; + +// src/lib/rest/HypixelAPIError.ts +var HypixelAPIError = class extends Error { + static { + __name(this, "HypixelAPIError"); + } + code; + constructor(message, code) { + super(message); + this.message = message; + this.code = code; + } +}; + +// src/lib/rest/RequestManager.ts +var import_async_queue = require("@sapphire/async-queue"); +var RequestManager2 = class { + static { + __name(this, "RequestManager"); + } + /** + * The hypixel.ts client instance + */ + client; + /** + * The base url of the hypixel API + */ + baseApiUrl; + /** + * Queue for requests + * @see {@link https://npmjs.com/@sapphire/async-queue} + */ + queue; + constructor(client) { + this.client = client; + this.baseApiUrl = client.options?.baseApiUrl ?? "https://api.hypixel.net"; + this.queue = new import_async_queue.AsyncQueue(); + } + /** + * Makes the api request and pushes it to the request queue + * @param path The path/endpoint to make the request to + * @param sendAPIKey Whether or not to send the apiKey with this request + */ + async execute(path, sendAPIKey) { + await this.queue.wait(); + try { + const request = await new ApiRequest(this, { path, sendAPIKey }).make(); + return request.json(); + } finally { + this.queue.shift(); + } + } +}; + +// src/lib/Client.ts +var Client = class { + static { + __name(this, "Client"); + } + options; + requests; + players; + guilds; + resources; + others; + skyblock; + constructor(options) { + this.options = options ?? {}; + this.options.baseApiUrl = "https://api.hypixel.net"; + } + /** + * Starts the hypixel client (registers all managers) + * *NOTE*: This method must be called before further usage. + */ + start() { + this.registerManagers(); + return this; + } + /** + * Register all the managers + */ + registerManagers() { + this.requests = new RequestManager2(this); + this.players = new PlayerManager(this); + this.guilds = new GuildManager(this); + this.resources = new ResourceManager(this); + this.others = new OtherManager(this); + this.skyblock = new SkyBlockManager(this); + } +}; + +// src/lib/typings/managers/ResourceManager.d.ts +var VanityPetsRarity = /* @__PURE__ */ ((VanityPetsRarity2) => { + VanityPetsRarity2[VanityPetsRarity2["COMMON"] = 0] = "COMMON"; + VanityPetsRarity2[VanityPetsRarity2["RARE"] = 1] = "RARE"; + VanityPetsRarity2[VanityPetsRarity2["EPIC"] = 2] = "EPIC"; + VanityPetsRarity2[VanityPetsRarity2["LEGENDARY"] = 3] = "LEGENDARY"; + return VanityPetsRarity2; +})(VanityPetsRarity || {}); +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + ApiRequest, + Base, + BaseManager, + Client, + Guild, + GuildManager, + HypixelAPIError, + OtherManager, + Player, + PlayerManager, + RequestManager, + ResourceManager, + SkyBlockAuction, + SkyBlockManager, + SkyBlockMuseum, + SkyBlockProfile, + Util, + VanityPetsRarity +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/cjs/lib/index.js.map b/dist/cjs/lib/index.js.map new file mode 100644 index 0000000..c750551 --- /dev/null +++ b/dist/cjs/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/lib/index.ts","../../../src/lib/managers/BaseManager.ts","../../../src/lib/errors/HypixelTSError.ts","../../../src/lib/classes/Base.ts","../../../src/lib/classes/Guild.ts","../../../src/lib/managers/GuildManager.ts","../../../src/lib/managers/OtherManager.ts","../../../src/lib/classes/Player.ts","../../../src/lib/classes/SkyBlockAuction.ts","../../../src/lib/classes/SkyBlockProfile.ts","../../../src/lib/classes/SkyBlockMuseum.ts","../../../src/lib/classes/Util.ts","../../../src/lib/errors/Messages.ts","../../../src/lib/managers/PlayerManager.ts","../../../src/lib/managers/ResourceManager.ts","../../../src/lib/managers/SkyBlockManager.ts","../../../src/lib/rest/ApiRequest.ts","../../../src/lib/rest/HypixelAPIError.ts","../../../src/lib/rest/RequestManager.ts","../../../src/lib/Client.ts","../../../src/lib/typings/managers/ResourceManager.d.ts"],"sourcesContent":["export * from './Client';\r\nexport * from './rest/index';\r\nexport * from './managers/index';\r\nexport * from './classes/index';\r\nexport * from './typings/index';\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APIGuild } from '../typings';\r\n\r\n/**\r\n * The guild class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get}\r\n */\r\nexport class Guild extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Guild data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIGuild) {\r\n\t\tsuper(client);\r\n\t\tdata.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport { Guild } from '../classes/Guild';\r\nimport type { APIGuild } from '../typings';\r\nimport type { Client } from '../Client';\r\n\r\n/**\r\n * Guild related endpoints\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class GuildManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid\r\n\t * @param identifier The id/name of the guild or the uuid of the player\r\n\t * @param type The type of identifier you're passing (id/name of guild, player uuid)\r\n\t */\r\n\tpublic async fetch(identifier: string, type: 'id' | 'name' | 'player') {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'type');\r\n\t\tif (type !== 'id' && type !== 'name' && type !== 'player')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'GuildManager', 'fetch', 'type', ['id', 'name', 'player']);\r\n\r\n\t\tconst { guild } = await this.makeGetRequest<{ guild: APIGuild | null }>(`/guild?${type}=${identifier}`);\r\n\t\treturn guild ? new Guild(this.client, guild) : null;\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport type {\r\n\tActiveNetworkBoostersResponse,\r\n\tCurrentPlayerCountsResponse,\r\n\tCurrentLeaderboardsResponse,\r\n\tPunishmentStatisticsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Other endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/Other}\r\n */\r\nexport class OtherManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all active network boosters\r\n\t */\r\n\tpublic async fetchActiveNetworkBoosters(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/boosters');\r\n\t\treturn {\r\n\t\t\tboosters: data.boosters,\r\n\t\t\tboosterState: data.boosterState\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current player counts across all games\r\n\t */\r\n\tpublic async fetchCurrentPlayerCounts(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/counts');\r\n\t\treturn {\r\n\t\t\tplayerCount: data.playerCount,\r\n\t\t\tgames: data.games\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current leaderboards\r\n\t */\r\n\tpublic async fetchCurrentLeaderboards(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/leaderboards');\r\n\t\treturn {\r\n\t\t\tleaderboards: data.leaderboards\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch punishment statistics\r\n\t */\r\n\tpublic async fetchPunishmentStatistics(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/punishmentstats');\r\n\t\treturn {\r\n\t\t\twatchdog_lastMinute: data.watchdog_lastMinute,\r\n\t\t\tstaff_rollingDaily: data.staff_rollingDaily,\r\n\t\t\twatchdog_total: data.watchdog_total,\r\n\t\t\twatchdog_rollingDaily: data.watchdog_rollingDaily,\r\n\t\t\tstaff_total: data.staff_total\r\n\t\t};\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { Client } from '../Client';\r\nimport { APIPlayer } from '../typings';\r\n\r\nexport interface Player extends APIPlayer {}\r\n/**\r\n * The player class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get}\r\n */\r\nexport class Player extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Player data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIPlayer) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the SkyBlock profiles of this player\r\n\t * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles}\r\n\t */\r\n\tpublic async fetchSkyBlockProfiles() {\r\n\t\treturn this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockAuction } from '../typings';\r\n\r\nexport interface SkyBlockAuction extends APISkyBlockAuction {}\r\n/**\r\n * The sky block auction class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get}\r\n */\r\nexport class SkyBlockAuction extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock auction data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockAuction) {\r\n\t\tsuper(client);\r\n\t\tif ('_id' in data) data.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockProfile } from '../typings';\r\n\r\nexport interface SkyBlockProfile extends APISkyBlockProfile {}\r\n/**\r\n * The SkyBlockProfile class.\r\n * @category Classes\r\n * @Group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get}\r\n */\r\nexport class SkyBlockProfile extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockProfile) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockMuseum } from '../typings';\r\n\r\nexport interface SkyBlockMuseum extends APISkyBlockMuseum {}\r\n/**\r\n * The SkyBlockMuseum class.\r\n * @category Classes\r\n * @Group Classes\r\n */\r\nexport class SkyBlockMuseum extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockMuseum) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport type { GetUsernameResponse, GetUUIDResponse } from '../typings';\r\n\r\n/**\r\n * Utility functions\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Util extends Base {\r\n\t/**\r\n\t * Get the UUID of a player by providing their name\r\n\t * @param name The name of the player\r\n\t */\r\n\tpublic static async getUUID(name: string): Promise {\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`);\r\n\t\t\tconst json = (await data.json()) as GetUUIDResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_UUID_ERROR', json.errorMessage, data.status);\r\n\t\t\treturn json.id;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_UUID_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Get player's name from their UUID\r\n\t * @param uuid The uuid of the player\r\n\t */\r\n\tpublic static async getUsername(uuid: string): Promise {\r\n\t\tif (!this.isUUID(uuid)) {\r\n\t\t\tthrow new HypixelTSError('NOT_UUID');\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/user/profile/${uuid}`);\r\n\t\t\tconst json = (await data.json()) as GetUsernameResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_USERNAME_ERROR', json.errorMessage, data.status);\r\n\r\n\t\t\treturn json.name;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_USERNAME_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Check whether the provided UUID is a valid UUID or not\r\n\t * @param uuid The UUID to check\r\n\t */\r\n\tpublic static isUUID(uuid: string) {\r\n\t\tconst regexStripped = /^[0-9a-f]{32}$/i;\r\n\t\tconst regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}$/i;\r\n\t\treturn regexStripped.test(uuid) || regexFull.test(uuid);\r\n\t}\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n","import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport { Player, Util } from '../classes/index';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport type { APIPlayer, GetRecentlyPlayedGamesResponse, GetStatusResponse } from '../typings';\r\n\r\n/**\r\n * Player related endpoints.\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class PlayerManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a player using their username or uuid\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async fetch(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'fetch', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { player } = await this.makeGetRequest<{ player: APIPlayer }>(`/player?uuid=${uuid}`);\r\n\t\treturn new Player(this.client, player);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the recently played games of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getRecentlyPlayedGames(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getRecentlyPlayedGames', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { games } = await this.makeGetRequest<{ games: GetRecentlyPlayedGamesResponse[] }>(`/recentgames?uuid=${uuid}`);\r\n\t\treturn games;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the status of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getStatus(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getStatus', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { session } = await this.makeGetRequest<{ session: GetStatusResponse }>(`/status?uuid=${uuid}`);\r\n\t\treturn session;\r\n\t}\r\n\r\n\t/**\r\n\t * Resolves the username to a uuid for use in requests\r\n\t * @param identifier The username (or uuid) of the player\r\n\t */\r\n\tprivate async getUUID(identifier: string) {\r\n\t\tconst isUUID = Util.isUUID(identifier);\r\n\r\n\t\tif (!isUUID) {\r\n\t\t\tconst uuid = await Util.getUUID(identifier);\r\n\t\t\treturn uuid;\r\n\t\t}\r\n\r\n\t\treturn identifier;\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport type { Client } from '../Client';\r\nimport type {\r\n\tVanityPetsResponse,\r\n\tAchievementsResponse,\r\n\tChallengesResponse,\r\n\tGameInformationResponse,\r\n\tGuildAchievementsResponse,\r\n\tQuestsResponse,\r\n\tVanityCompanionsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Resource endpoints.\r\n *\r\n * **Note**: API Key authorization is not required to use this manager.\r\n *\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class ResourceManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, false);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information about Hypixel games\r\n\t */\r\n\tpublic async fetchGameInformation() {\r\n\t\treturn this.makeGetRequest('/resources/games');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all achievements\r\n\t */\r\n\tpublic async fetchAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all challenges\r\n\t */\r\n\tpublic async fetchChallenges() {\r\n\t\treturn this.makeGetRequest('/resources/challenges');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all quests\r\n\t */\r\n\tpublic async fetchQuests() {\r\n\t\treturn this.makeGetRequest('/resources/quests');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all guild achievements\r\n\t */\r\n\tpublic async fetchGuildAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/guilds/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity pets\r\n\t */\r\n\tpublic async fetchVanityPets() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/pets');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity companions\r\n\t */\r\n\tpublic async fetchVanityCompanions() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/companions');\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport { SkyBlockProfile, SkyBlockAuction, SkyBlockMuseum } from '../classes/index';\r\nimport type { Client } from '../Client';\r\nimport {\r\n\ttype APISkyBlockProfile,\r\n\ttype FetchCollectionsResponse,\r\n\ttype FetchSkillsResponse,\r\n\ttype FetchItemsResponse,\r\n\ttype FetchElectionAndMayorResponse,\r\n\ttype FetchActiveBingoGoalsResponse,\r\n\ttype FetchNewsResponse,\r\n\ttype APISkyBlockAuction,\r\n\ttype FetchActiveAuctionsResponse,\r\n\ttype FetchBazaarResponse,\r\n\ttype RecentlyEndedAuctionsResponse,\r\n\ttype FetchBingoDataResponse,\r\n\ttype FetchFireSalesResponse,\r\n\ttype FetchFireSalesResponseFireSale,\r\n\tAPISkyBlockMuseum\r\n} from '../typings';\r\n\r\n/**\r\n * Skyblock related endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock}\r\n */\r\nexport class SkyBlockManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding collections in the SkyBlock game\r\n\t */\r\n\tpublic async fetchCollections(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/collections');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding skills in the SkyBlock game\r\n\t */\r\n\tpublic async fetchSkills(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/skills');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections,\r\n\t\t\tskills: data.skills\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding items in the SkyBlock game\r\n\t */\r\n\tpublic async fetchItems(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/items');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current mayor and ongoing election in SkyBlock\r\n\t */\r\n\tpublic async fetchElectionAndMayor(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/election');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tmayor: data.mayor,\r\n\t\t\tcurrent: data.current\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current bingo event and its goals\r\n\t */\r\n\tpublic async fetchActiveBingoGoals(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/bingo');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tid: data.id,\r\n\t\t\tgoals: data.goals\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch SkyBlock news\r\n\t */\r\n\tpublic async fetchNews() {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/news');\r\n\t\treturn {\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock auction.\r\n\t * @param identifier The idenitifer you're using to fetch the auction\r\n\t * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`)\r\n\t * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`.\r\n\t */\r\n\tpublic async fetchAuction(\r\n\t\tidentifier: string,\r\n\t\ttype: 'uuid' | 'player' | 'profile',\r\n\t\traw = false\r\n\t): Promise {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'type');\r\n\t\tif (type !== 'uuid' && type !== 'player' && type !== 'profile')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchAuction', 'type', ['uuid', 'player', 'profile']);\r\n\r\n\t\tconst { auctions } = await this.makeGetRequest<{ auctions: APISkyBlockAuction[] }>(`/skyblock/auction?${type}=${identifier}`);\r\n\r\n\t\tif (!raw) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn parsed;\r\n\t\t}\r\n\r\n\t\treturn auctions;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active auctions (sorted by last updated first and paginated)\r\n\t * @param page The page number\r\n\t * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`.\r\n\t */\r\n\tpublic async fetchActiveAuctions(page?: number, resolveAuctions = true) {\r\n\t\tif (page && typeof page !== 'number')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchActiveAuctions', 'page', ['number']);\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/auctions${page ? '?page=' + page : ''}`);\r\n\r\n\t\tif (resolveAuctions) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of data.auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn {\r\n\t\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\t\tpage: data.page,\r\n\t\t\t\ttotalPages: data.totalPages,\r\n\t\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\t\tauctions: parsed\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tpage: data.page,\r\n\t\t\ttotalPages: data.totalPages,\r\n\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch recently ended auctions (auctions which ended in the last 60 seconds).\r\n\t */\r\n\tpublic async fetchRecentlyEndedAuctions(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/auctions_ended');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bazaar items\r\n\t */\r\n\tpublic async fetchBazaar(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/bazaar');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tproducts: data.products\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchProfile(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchProfile', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockProfile(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchMuseum(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchMuseum', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockMuseum(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profiles of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchPlayerSkyBlockProfiles(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchPlayerSkyBlockProfiles', 'playerUuid');\r\n\r\n\t\tconst { profiles } = await this.makeGetRequest<{ profiles: APISkyBlockProfile[] }>(`/skyblock/profiles?uuid=${playerUuid}`);\r\n\t\tconst parsed = [];\r\n\r\n\t\tfor (const profile of profiles) {\r\n\t\t\tparsed.push(new SkyBlockProfile(this.client, profile));\r\n\t\t}\r\n\r\n\t\treturn parsed;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bingo data of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchBingoData(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchBingoData', 'playerUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`);\r\n\t\treturn {\r\n\t\t\tevents: data.events\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active or upcoming Fire Sales for SkyBlock\r\n\t */\r\n\tpublic async fetchFireSales(): Promise {\r\n\t\tconst { sales } = await this.makeGetRequest('/skyblock/firesales');\r\n\t\treturn sales;\r\n\t}\r\n}\r\n","import { RequestManager, HypixelAPIError, type HypixelAPIErrorResponse } from './index';\r\nimport { HypixelTSError } from '../errors/index';\r\n\r\n/**\r\n * The options supplied to the request\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface ApiRequestOptions {\r\n\t/**\r\n\t * The request path/endpoint\r\n\t */\r\n\tpath: string;\r\n\r\n\t/**\r\n\t * The request method, only `GET` is supported\r\n\t */\r\n\tmethod?: 'GET';\r\n\r\n\t/**\r\n\t * Whether to send the API key for this request\r\n\t */\r\n\tsendAPIKey?: boolean;\r\n}\r\n\r\n/**\r\n * Handles (sending/building options) requests\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class ApiRequest {\r\n\t/**\r\n\t * The request manager instance\r\n\t */\r\n\tpublic requests: RequestManager;\r\n\r\n\t/**\r\n\t * The options of this request\r\n\t */\r\n\tpublic options: ApiRequestOptions;\r\n\r\n\tpublic constructor(requestManager: RequestManager, options: ApiRequestOptions) {\r\n\t\tthis.requests = requestManager;\r\n\t\tthis.options = options;\r\n\t}\r\n\r\n\t/**\r\n\t * Makes a request with the options provided.\r\n\t */\r\n\tpublic async make() {\r\n\t\tconst options = this.buildOptions();\r\n\r\n\t\tconst res = await fetch(options.url, {\r\n\t\t\t...options\r\n\t\t});\r\n\r\n\t\tif (!res.ok) {\r\n\t\t\tconst error = (await res.json()) as HypixelAPIErrorResponse;\r\n\t\t\tthrow new HypixelAPIError(error?.cause ?? res.statusText, res.status);\r\n\t\t}\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an object containing the options to be passed to the request\r\n\t */\r\n\tpublic buildOptions() {\r\n\t\tconst apiKey = this.requests.client.options?.apiKey;\r\n\r\n\t\tconst headers: Record = {\r\n\t\t\t'Content-Type': 'application/json'\r\n\t\t};\r\n\r\n\t\tif (this.options.sendAPIKey) {\r\n\t\t\tif (!apiKey) throw new HypixelTSError('CLIENT_OPTIONS_MISSING', 'apiKey');\r\n\t\t\theaders['API-Key'] = apiKey;\r\n\t\t}\r\n\r\n\t\tconst options = {\r\n\t\t\turl: `${this.requests.baseApiUrl}${this.options.path}`,\r\n\t\t\tmethod: this.options.method ?? 'GET',\r\n\t\t\theaders\r\n\t\t};\r\n\r\n\t\treturn options;\r\n\t}\r\n}\r\n","/**\r\n * Response body when an error is returned by the hypixel api\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface HypixelAPIErrorResponse {\r\n\t/**\r\n\t * Whether or not the request is successful\r\n\t */\r\n\tsuccess: boolean;\r\n\r\n\t/**\r\n\t * The message explaining the error\r\n\t */\r\n\tcause: string;\r\n}\r\n\r\n/**\r\n * Error thrown when an error is encountered while querying the hypixel API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class HypixelAPIError extends Error {\r\n\tpublic code: number;\r\n\r\n\tpublic constructor(message: string, code: number) {\r\n\t\tsuper(message);\r\n\t\tthis.message = message;\r\n\t\tthis.code = code;\r\n\t}\r\n}\r\n","import { AsyncQueue } from '@sapphire/async-queue';\r\nimport { ApiRequest } from './ApiRequest';\r\nimport { Client } from '../Client';\r\n\r\n/**\r\n * Manages the requests to the API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class RequestManager {\r\n\t/**\r\n\t * The hypixel.ts client instance\r\n\t */\r\n\tpublic client: Client;\r\n\r\n\t/**\r\n\t * The base url of the hypixel API\r\n\t */\r\n\tpublic baseApiUrl: string;\r\n\r\n\t/**\r\n\t * Queue for requests\r\n\t * @see {@link https://npmjs.com/@sapphire/async-queue}\r\n\t */\r\n\tprivate queue: AsyncQueue;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t\tthis.baseApiUrl = client.options?.baseApiUrl ?? 'https://api.hypixel.net';\r\n\t\tthis.queue = new AsyncQueue();\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the api request and pushes it to the request queue\r\n\t * @param path The path/endpoint to make the request to\r\n\t * @param sendAPIKey Whether or not to send the apiKey with this request\r\n\t */\r\n\tpublic async execute(path: string, sendAPIKey: boolean) {\r\n\t\tawait this.queue.wait();\r\n\t\ttry {\r\n\t\t\tconst request = await new ApiRequest(this, { path, sendAPIKey }).make();\r\n\t\t\treturn request.json() as T;\r\n\t\t} finally {\r\n\t\t\tthis.queue.shift();\r\n\t\t}\r\n\t}\r\n}\r\n","import { PlayerManager, GuildManager, ResourceManager, OtherManager, SkyBlockManager } from './managers/index';\r\nimport { RequestManager } from './rest/index';\r\nimport type { ClientOptions } from '../index';\r\n\r\n/**\r\n * The hypixel.ts client.\r\n * @category Classes\r\n */\r\nexport class Client {\r\n\tpublic options?: ClientOptions;\r\n\tpublic requests!: RequestManager;\r\n\tpublic players!: PlayerManager;\r\n\tpublic guilds!: GuildManager;\r\n\tpublic resources!: ResourceManager;\r\n\tpublic others!: OtherManager;\r\n\tpublic skyblock!: SkyBlockManager;\r\n\r\n\tpublic constructor(options?: ClientOptions) {\r\n\t\tthis.options = options ?? {};\r\n\t\tthis.options.baseApiUrl = 'https://api.hypixel.net';\r\n\t}\r\n\r\n\t/**\r\n\t * Starts the hypixel client (registers all managers)\r\n\t * *NOTE*: This method must be called before further usage.\r\n\t */\r\n\tpublic start() {\r\n\t\tthis.registerManagers();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Register all the managers\r\n\t */\r\n\tprivate registerManagers() {\r\n\t\tthis.requests = new RequestManager(this);\r\n\t\tthis.players = new PlayerManager(this);\r\n\t\tthis.guilds = new GuildManager(this);\r\n\t\tthis.resources = new ResourceManager(this);\r\n\t\tthis.others = new OtherManager(this);\r\n\t\tthis.skyblock = new SkyBlockManager(this);\r\n\t}\r\n}\r\n","/**\r\n * All other responses extend this interface as they have the common property 'lastUpdated'.\r\n * @category Interfaces\r\n */\r\nexport interface BaseResourceResponse {\r\n\tlastUpdated: number;\r\n}\r\n\r\n/**\r\n * Information about hypixel games returned by the hypixel API\r\n * @category Interfaces\r\n * @see {@link ResourceManager.fetchGameInformation}\r\n */\r\nexport interface GameInformationResponse extends BaseResourceResponse {\r\n\tgames: Record;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface GameInformationResponseGame {\r\n\tid: number;\r\n\tname: string;\r\n\tdatabaseName: string;\r\n\tmodeNames: Record;\r\n\tlegacy?: boolean;\r\n\tretired?: boolean;\r\n}\r\n\r\n/**\r\n * All achievements returned by the hypixel API.\r\n * @category Interfaces\r\n */\r\nexport interface AchievementsResponse extends BaseResourceResponse {\r\n\tachievements: Record;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface AchievementsResponseAchievement {\r\n\tone_time: Record;\r\n\ttiered: Record;\r\n\ttotal_points: number;\r\n\ttotal_legacy_points: number;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface AchievementsResponseAchievementOnetime {\r\n\tpoints: number;\r\n\tname: string;\r\n\tdescription: string;\r\n\tgamePercentUnlocked: number;\r\n\tglobalPercentUnlocked: number;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface AchievementsResponseAchievementTiered {\r\n\tname: string;\r\n\tdescription: string;\r\n\ttiers: { tier: number; points: number; amount: number }[];\r\n}\r\n\r\n/**\r\n * All challenges returned by hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface ChallengesResponse extends BaseResourceResponse {\r\n\tchallenges: Record;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface ChallengesResponseChallenge {\r\n\tid: string;\r\n\tname: string;\r\n\trewards: { type: string; amount: number }[];\r\n}\r\n\r\n/**\r\n * All quests returned by the hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface QuestsResponse extends BaseResourceResponse {\r\n\tquests: Record;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface QuestsResponseQuest {\r\n\tid: string;\r\n\tname: string;\r\n\tdescription: string;\r\n\trewards: { type: string; amount: number }[];\r\n\tobjectives: { id: string; type: string }[];\r\n\trequirements: { type: string }[];\r\n}\r\n\r\n/**\r\n * All guild achievements returned by the hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface GuildAchievementsResponse extends BaseResourceResponse {\r\n\tone_time: AchievementsResponseAchievementOnetime;\r\n\ttiered: AchievementsResponseAchievementTiered;\r\n}\r\n\r\n/**\r\n * All vanity pets returned by the hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface VanityPetsResponse extends BaseResourceResponse {\r\n\ttypes: VanityPetsResponseType[];\r\n\trarities: VanityPetsResponseRarity[];\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface VanityPetsResponseType {\r\n\tkey: string;\r\n\tname: string;\r\n\trarity: VanityPetsRarity;\r\n\tpackage: string;\r\n}\r\n\r\n/**\r\n * @category Interfaces\r\n */\r\nexport interface VanityPetsResponseRarity {\r\n\tname: VanityPetsRarity;\r\n\tcolor: string;\r\n}\r\n\r\n/**\r\n * @category Enumerations\r\n */\r\nexport enum VanityPetsRarity {\r\n\tCOMMON,\r\n\tRARE,\r\n\tEPIC,\r\n\tLEGENDARY\r\n}\r\n\r\n/**\r\n * All vanity companions returned by the hypixel API\r\n * @category Interfaces\r\n */\r\nexport interface VanityCompanionsResponse extends VanityPetsResponse {}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,cAAN,MAAkB;AAAA,EAPzB,OAOyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAId;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEH,YAAY,QAAgB,cAAuB;AACzD,SAAK,SAAS;AACd,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAgB,eAAkB,MAAc;AAC/C,WAAO,KAAK,OAAO,SAAS,QAAW,MAAM,KAAK,YAAY;AAAA,EAC/D;AACD;;;AC/BA,IAAM,WAAW,oBAAI,IAA2C;AAEzD,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAJ1C,OAI0C;AAAA;AAAA;AAAA,EAClC,YAAY,QAAgB,MAAa;AAC/C,UAAM,WAAW,KAAK,IAAI,CAAC;AAE3B,aAAS,WAAWC,MAAaC,OAAa;AAC7C,UAAI,OAAOD,SAAQ;AAAU,cAAM,IAAI,MAAM,6CAA6C;AAC1F,YAAM,MAAM,SAAS,IAAIA,IAAG;AAE5B,UAAI,CAAC;AAAK,cAAM,IAAI,MAAM,oDAAoDA,IAAG,EAAE;AACnF,UAAI,OAAO,QAAQ;AAAY,eAAO,IAAI,GAAGC,KAAI;AACjD,UAAI,CAACA,MAAK;AAAQ,eAAO;AAEzB,MAA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AK,MAAM,KAAK;AACtB,QAAI;AACH,YAAM,UAAU,MAAM,IAAI,WAAW,MAAM,EAAE,MAAM,WAAW,CAAC,EAAE,KAAK;AACtE,aAAO,QAAQ,KAAK;AAAA,IACrB,UAAE;AACD,WAAK,MAAM,MAAM;AAAA,IAClB;AAAA,EACD;AACD;;;ACtCO,IAAM,SAAN,MAAa;AAAA,EARpB,OAQoB;AAAA;AAAA;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,SAAyB;AAC3C,SAAK,UAAU,WAAW,CAAC;AAC3B,SAAK,QAAQ,aAAa;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,QAAQ;AACd,SAAK,iBAAiB;AACtB,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB;AAC1B,SAAK,WAAW,IAAIC,gBAAe,IAAI;AACvC,SAAK,UAAU,IAAI,cAAc,IAAI;AACrC,SAAK,SAAS,IAAI,aAAa,IAAI;AACnC,SAAK,YAAY,IAAI,gBAAgB,IAAI;AACzC,SAAK,SAAS,IAAI,aAAa,IAAI;AACnC,SAAK,WAAW,IAAI,gBAAgB,IAAI;AAAA,EACzC;AACD;;;ACqGO,IAAK,mBAAL,kBAAKC,sBAAL;AACN,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AAJW,SAAAA;AAAA,GAAA;","names":["RequestManager","key","args","messages","RequestManager","RequestManager","VanityPetsRarity"]} \ No newline at end of file diff --git a/dist/cjs/lib/managers/BaseManager.d.ts b/dist/cjs/lib/managers/BaseManager.d.ts new file mode 100644 index 0000000..bb8e9d1 --- /dev/null +++ b/dist/cjs/lib/managers/BaseManager.d.ts @@ -0,0 +1,2 @@ +export { BaseManager } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/managers/BaseManager.js b/dist/cjs/lib/managers/BaseManager.js new file mode 100644 index 0000000..3ef136f --- /dev/null +++ b/dist/cjs/lib/managers/BaseManager.js @@ -0,0 +1,58 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/managers/BaseManager.ts +var BaseManager_exports = {}; +__export(BaseManager_exports, { + BaseManager: () => BaseManager +}); +module.exports = __toCommonJS(BaseManager_exports); +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + BaseManager +}); +//# sourceMappingURL=BaseManager.js.map \ No newline at end of file diff --git a/dist/cjs/lib/managers/BaseManager.js.map b/dist/cjs/lib/managers/BaseManager.js.map new file mode 100644 index 0000000..63be533 --- /dev/null +++ b/dist/cjs/lib/managers/BaseManager.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/BaseManager.ts"],"sourcesContent":["import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,IAAM,cAAN,MAAkB;AAAA,EAPzB,OAOyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAId;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEH,YAAY,QAAgB,cAAuB;AACzD,SAAK,SAAS;AACd,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAgB,eAAkB,MAAc;AAC/C,WAAO,KAAK,OAAO,SAAS,QAAW,MAAM,KAAK,YAAY;AAAA,EAC/D;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/managers/GuildManager.d.ts b/dist/cjs/lib/managers/GuildManager.d.ts new file mode 100644 index 0000000..089e445 --- /dev/null +++ b/dist/cjs/lib/managers/GuildManager.d.ts @@ -0,0 +1,2 @@ +export { GuildManager } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/managers/GuildManager.js b/dist/cjs/lib/managers/GuildManager.js new file mode 100644 index 0000000..ca7cf8c --- /dev/null +++ b/dist/cjs/lib/managers/GuildManager.js @@ -0,0 +1,140 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/managers/GuildManager.ts +var GuildManager_exports = {}; +__export(GuildManager_exports, { + GuildManager: () => GuildManager +}); +module.exports = __toCommonJS(GuildManager_exports); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/Guild.ts +var Guild = class extends Base { + static { + __name(this, "Guild"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client, data) { + super(client); + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/managers/GuildManager.ts +var GuildManager = class extends BaseManager { + static { + __name(this, "GuildManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid + * @param identifier The id/name of the guild or the uuid of the player + * @param type The type of identifier you're passing (id/name of guild, player uuid) + */ + async fetch(identifier, type) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "type"); + if (type !== "id" && type !== "name" && type !== "player") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "GuildManager", "fetch", "type", ["id", "name", "player"]); + const { guild } = await this.makeGetRequest(`/guild?${type}=${identifier}`); + return guild ? new Guild(this.client, guild) : null; + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + GuildManager +}); +//# sourceMappingURL=GuildManager.js.map \ No newline at end of file diff --git a/dist/cjs/lib/managers/GuildManager.js.map b/dist/cjs/lib/managers/GuildManager.js.map new file mode 100644 index 0000000..7a561d0 --- /dev/null +++ b/dist/cjs/lib/managers/GuildManager.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/GuildManager.ts","../../../../src/lib/managers/BaseManager.ts","../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/classes/Base.ts","../../../../src/lib/classes/Guild.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport { Guild } from '../classes/Guild';\r\nimport type { APIGuild } from '../typings';\r\nimport type { Client } from '../Client';\r\n\r\n/**\r\n * Guild related endpoints\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class GuildManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid\r\n\t * @param identifier The id/name of the guild or the uuid of the player\r\n\t * @param type The type of identifier you're passing (id/name of guild, player uuid)\r\n\t */\r\n\tpublic async fetch(identifier: string, type: 'id' | 'name' | 'player') {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'type');\r\n\t\tif (type !== 'id' && type !== 'name' && type !== 'player')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'GuildManager', 'fetch', 'type', ['id', 'name', 'player']);\r\n\r\n\t\tconst { guild } = await this.makeGetRequest<{ guild: APIGuild | null }>(`/guild?${type}=${identifier}`);\r\n\t\treturn guild ? new Guild(this.client, guild) : null;\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APIGuild } from '../typings';\r\n\r\n/**\r\n * The guild class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get}\r\n */\r\nexport class Guild extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Guild data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIGuild) {\r\n\t\tsuper(client);\r\n\t\tdata.id = data._id;\r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AAA;AAAA;AAAA;AAAA,EAKxB,YAAY,QAAgB,MAAgB;AAClD,UAAM,MAAM;AACZ,SAAK,KAAK,KAAK;AACf,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;;;AJTO,IAAM,eAAN,cAA2B,YAAY;AAAA,EAX9C,OAW8C;AAAA;AAAA;AAAA,EACtC,YAAY,QAAgB;AAClC,UAAM,QAAQ,IAAI;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,MAAM,YAAoB,MAAgC;AACtE,QAAI,CAAC;AAAY,YAAM,IAAI,eAAe,yBAAyB,gBAAgB,SAAS,YAAY;AACxG,QAAI,CAAC;AAAM,YAAM,IAAI,eAAe,yBAAyB,gBAAgB,SAAS,MAAM;AAC5F,QAAI,SAAS,QAAQ,SAAS,UAAU,SAAS;AAChD,YAAM,IAAI,eAAe,0BAA0B,gBAAgB,SAAS,QAAQ,CAAC,MAAM,QAAQ,QAAQ,CAAC;AAE7G,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,eAA2C,UAAU,IAAI,IAAI,UAAU,EAAE;AACtG,WAAO,QAAQ,IAAI,MAAM,KAAK,QAAQ,KAAK,IAAI;AAAA,EAChD;AACD;","names":["key","args"]} \ No newline at end of file diff --git a/dist/cjs/lib/managers/OtherManager.d.ts b/dist/cjs/lib/managers/OtherManager.d.ts new file mode 100644 index 0000000..e4dc87b --- /dev/null +++ b/dist/cjs/lib/managers/OtherManager.d.ts @@ -0,0 +1,2 @@ +export { OtherManager } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/managers/OtherManager.js b/dist/cjs/lib/managers/OtherManager.js new file mode 100644 index 0000000..aa495bc --- /dev/null +++ b/dist/cjs/lib/managers/OtherManager.js @@ -0,0 +1,112 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/managers/OtherManager.ts +var OtherManager_exports = {}; +__export(OtherManager_exports, { + OtherManager: () => OtherManager +}); +module.exports = __toCommonJS(OtherManager_exports); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; + +// src/lib/managers/OtherManager.ts +var OtherManager = class extends BaseManager { + static { + __name(this, "OtherManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch all active network boosters + */ + async fetchActiveNetworkBoosters() { + const data = await this.makeGetRequest("/boosters"); + return { + boosters: data.boosters, + boosterState: data.boosterState + }; + } + /** + * Fetch current player counts across all games + */ + async fetchCurrentPlayerCounts() { + const data = await this.makeGetRequest("/counts"); + return { + playerCount: data.playerCount, + games: data.games + }; + } + /** + * Fetch current leaderboards + */ + async fetchCurrentLeaderboards() { + const data = await this.makeGetRequest("/leaderboards"); + return { + leaderboards: data.leaderboards + }; + } + /** + * Fetch punishment statistics + */ + async fetchPunishmentStatistics() { + const data = await this.makeGetRequest("/punishmentstats"); + return { + watchdog_lastMinute: data.watchdog_lastMinute, + staff_rollingDaily: data.staff_rollingDaily, + watchdog_total: data.watchdog_total, + watchdog_rollingDaily: data.watchdog_rollingDaily, + staff_total: data.staff_total + }; + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + OtherManager +}); +//# sourceMappingURL=OtherManager.js.map \ No newline at end of file diff --git a/dist/cjs/lib/managers/OtherManager.js.map b/dist/cjs/lib/managers/OtherManager.js.map new file mode 100644 index 0000000..457687d --- /dev/null +++ b/dist/cjs/lib/managers/OtherManager.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/OtherManager.ts","../../../../src/lib/managers/BaseManager.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport type {\r\n\tActiveNetworkBoostersResponse,\r\n\tCurrentPlayerCountsResponse,\r\n\tCurrentLeaderboardsResponse,\r\n\tPunishmentStatisticsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Other endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/Other}\r\n */\r\nexport class OtherManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all active network boosters\r\n\t */\r\n\tpublic async fetchActiveNetworkBoosters(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/boosters');\r\n\t\treturn {\r\n\t\t\tboosters: data.boosters,\r\n\t\t\tboosterState: data.boosterState\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current player counts across all games\r\n\t */\r\n\tpublic async fetchCurrentPlayerCounts(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/counts');\r\n\t\treturn {\r\n\t\t\tplayerCount: data.playerCount,\r\n\t\t\tgames: data.games\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current leaderboards\r\n\t */\r\n\tpublic async fetchCurrentLeaderboards(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/leaderboards');\r\n\t\treturn {\r\n\t\t\tleaderboards: data.leaderboards\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch punishment statistics\r\n\t */\r\n\tpublic async fetchPunishmentStatistics(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/punishmentstats');\r\n\t\treturn {\r\n\t\t\twatchdog_lastMinute: data.watchdog_lastMinute,\r\n\t\t\tstaff_rollingDaily: data.staff_rollingDaily,\r\n\t\t\twatchdog_total: data.watchdog_total,\r\n\t\t\twatchdog_rollingDaily: data.watchdog_rollingDaily,\r\n\t\t\tstaff_total: data.staff_total\r\n\t\t};\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,cAAN,MAAkB;AAAA,EAPzB,OAOyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAId;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEH,YAAY,QAAgB,cAAuB;AACzD,SAAK,SAAS;AACd,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAgB,eAAkB,MAAc;AAC/C,WAAO,KAAK,OAAO,SAAS,QAAW,MAAM,KAAK,YAAY;AAAA,EAC/D;AACD;;;ADlBO,IAAM,eAAN,cAA2B,YAAY;AAAA,EAf9C,OAe8C;AAAA;AAAA;AAAA,EACtC,YAAY,QAAgB;AAClC,UAAM,QAAQ,IAAI;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,6BAAqE;AACjF,UAAM,OAAO,MAAM,KAAK,eAA8C,WAAW;AACjF,WAAO;AAAA,MACN,UAAU,KAAK;AAAA,MACf,cAAc,KAAK;AAAA,IACpB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,2BAAiE;AAC7E,UAAM,OAAO,MAAM,KAAK,eAA4C,SAAS;AAC7E,WAAO;AAAA,MACN,aAAa,KAAK;AAAA,MAClB,OAAO,KAAK;AAAA,IACb;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,2BAAiE;AAC7E,UAAM,OAAO,MAAM,KAAK,eAA4C,eAAe;AACnF,WAAO;AAAA,MACN,cAAc,KAAK;AAAA,IACpB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,4BAAmE;AAC/E,UAAM,OAAO,MAAM,KAAK,eAA6C,kBAAkB;AACvF,WAAO;AAAA,MACN,qBAAqB,KAAK;AAAA,MAC1B,oBAAoB,KAAK;AAAA,MACzB,gBAAgB,KAAK;AAAA,MACrB,uBAAuB,KAAK;AAAA,MAC5B,aAAa,KAAK;AAAA,IACnB;AAAA,EACD;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/managers/PlayerManager.d.ts b/dist/cjs/lib/managers/PlayerManager.d.ts new file mode 100644 index 0000000..0933ed5 --- /dev/null +++ b/dist/cjs/lib/managers/PlayerManager.d.ts @@ -0,0 +1,2 @@ +export { PlayerManager } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/managers/PlayerManager.js b/dist/cjs/lib/managers/PlayerManager.js new file mode 100644 index 0000000..79f086c --- /dev/null +++ b/dist/cjs/lib/managers/PlayerManager.js @@ -0,0 +1,244 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/managers/PlayerManager.ts +var PlayerManager_exports = {}; +__export(PlayerManager_exports, { + PlayerManager: () => PlayerManager +}); +module.exports = __toCommonJS(PlayerManager_exports); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/Player.ts +var Player = class extends Base { + static { + __name(this, "Player"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + async fetchSkyBlockProfiles() { + return this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid); + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/classes/Util.ts +var Util = class extends Base { + static { + __name(this, "Util"); + } + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static async getUUID(name) { + try { + const data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_UUID_ERROR", json.errorMessage, data.status); + return json.id; + } catch { + throw new HypixelTSError("GET_UUID_404"); + } + } + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static async getUsername(uuid) { + if (!this.isUUID(uuid)) { + throw new HypixelTSError("NOT_UUID"); + } + try { + const data = await fetch(`https://api.mojang.com/user/profile/${uuid}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_USERNAME_ERROR", json.errorMessage, data.status); + return json.name; + } catch { + throw new HypixelTSError("GET_USERNAME_404"); + } + } + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid) { + const regexStripped = /^[0-9a-f]{32}$/i; + const regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}$/i; + return regexStripped.test(uuid) || regexFull.test(uuid); + } +}; + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); + +// src/lib/managers/PlayerManager.ts +var PlayerManager = class extends BaseManager { + static { + __name(this, "PlayerManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a player using their username or uuid + * @param identifier The username/uuid of the player + */ + async fetch(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "fetch", "identifier"); + const uuid = await this.getUUID(identifier); + const { player } = await this.makeGetRequest(`/player?uuid=${uuid}`); + return new Player(this.client, player); + } + /** + * Fetch the recently played games of a player + * @param identifier The username/uuid of the player + */ + async getRecentlyPlayedGames(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getRecentlyPlayedGames", "identifier"); + const uuid = await this.getUUID(identifier); + const { games } = await this.makeGetRequest(`/recentgames?uuid=${uuid}`); + return games; + } + /** + * Fetch the status of a player + * @param identifier The username/uuid of the player + */ + async getStatus(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getStatus", "identifier"); + const uuid = await this.getUUID(identifier); + const { session } = await this.makeGetRequest(`/status?uuid=${uuid}`); + return session; + } + /** + * Resolves the username to a uuid for use in requests + * @param identifier The username (or uuid) of the player + */ + async getUUID(identifier) { + const isUUID = Util.isUUID(identifier); + if (!isUUID) { + const uuid = await Util.getUUID(identifier); + return uuid; + } + return identifier; + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + PlayerManager +}); +//# sourceMappingURL=PlayerManager.js.map \ No newline at end of file diff --git a/dist/cjs/lib/managers/PlayerManager.js.map b/dist/cjs/lib/managers/PlayerManager.js.map new file mode 100644 index 0000000..e88260c --- /dev/null +++ b/dist/cjs/lib/managers/PlayerManager.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/PlayerManager.ts","../../../../src/lib/managers/BaseManager.ts","../../../../src/lib/classes/Base.ts","../../../../src/lib/classes/Player.ts","../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/classes/Util.ts","../../../../src/lib/errors/Messages.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport { Player, Util } from '../classes/index';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport type { APIPlayer, GetRecentlyPlayedGamesResponse, GetStatusResponse } from '../typings';\r\n\r\n/**\r\n * Player related endpoints.\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class PlayerManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a player using their username or uuid\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async fetch(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'fetch', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { player } = await this.makeGetRequest<{ player: APIPlayer }>(`/player?uuid=${uuid}`);\r\n\t\treturn new Player(this.client, player);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the recently played games of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getRecentlyPlayedGames(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getRecentlyPlayedGames', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { games } = await this.makeGetRequest<{ games: GetRecentlyPlayedGamesResponse[] }>(`/recentgames?uuid=${uuid}`);\r\n\t\treturn games;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the status of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getStatus(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getStatus', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { session } = await this.makeGetRequest<{ session: GetStatusResponse }>(`/status?uuid=${uuid}`);\r\n\t\treturn session;\r\n\t}\r\n\r\n\t/**\r\n\t * Resolves the username to a uuid for use in requests\r\n\t * @param identifier The username (or uuid) of the player\r\n\t */\r\n\tprivate async getUUID(identifier: string) {\r\n\t\tconst isUUID = Util.isUUID(identifier);\r\n\r\n\t\tif (!isUUID) {\r\n\t\t\tconst uuid = await Util.getUUID(identifier);\r\n\t\t\treturn uuid;\r\n\t\t}\r\n\r\n\t\treturn identifier;\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { Client } from '../Client';\r\nimport { APIPlayer } from '../typings';\r\n\r\nexport interface Player extends APIPlayer {}\r\n/**\r\n * The player class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get}\r\n */\r\nexport class Player extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Player data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIPlayer) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the SkyBlock profiles of this player\r\n\t * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles}\r\n\t */\r\n\tpublic async fetchSkyBlockProfiles() {\r\n\t\treturn this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid);\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import { Base } from './Base';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport type { GetUsernameResponse, GetUUIDResponse } from '../typings';\r\n\r\n/**\r\n * Utility functions\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Util extends Base {\r\n\t/**\r\n\t * Get the UUID of a player by providing their name\r\n\t * @param name The name of the player\r\n\t */\r\n\tpublic static async getUUID(name: string): Promise {\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`);\r\n\t\t\tconst json = (await data.json()) as GetUUIDResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_UUID_ERROR', json.errorMessage, data.status);\r\n\t\t\treturn json.id;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_UUID_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Get player's name from their UUID\r\n\t * @param uuid The uuid of the player\r\n\t */\r\n\tpublic static async getUsername(uuid: string): Promise {\r\n\t\tif (!this.isUUID(uuid)) {\r\n\t\t\tthrow new HypixelTSError('NOT_UUID');\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/user/profile/${uuid}`);\r\n\t\t\tconst json = (await data.json()) as GetUsernameResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_USERNAME_ERROR', json.errorMessage, data.status);\r\n\r\n\t\t\treturn json.name;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_USERNAME_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Check whether the provided UUID is a valid UUID or not\r\n\t * @param uuid The UUID to check\r\n\t */\r\n\tpublic static isUUID(uuid: string) {\r\n\t\tconst regexStripped = /^[0-9a-f]{32}$/i;\r\n\t\tconst regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}$/i;\r\n\t\treturn regexStripped.test(uuid) || regexFull.test(uuid);\r\n\t}\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n"],"mappings":";;;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,EAMA,MAAa,uBAAuB,YAAoB;AACvD,QAAI,CAAC;AAAY,YAAM,IAAI,eAAe,yBAAyB,iBAAiB,0BAA0B,YAAY;AAE1H,UAAM,OAAO,MAAM,KAAK,QAAQ,UAAU;AAC1C,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,eAA4D,qBAAqB,IAAI,EAAE;AACpH,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,UAAU,YAAoB;AAC1C,QAAI,CAAC;AAAY,YAAM,IAAI,eAAe,yBAAyB,iBAAiB,aAAa,YAAY;AAE7G,UAAM,OAAO,MAAM,KAAK,QAAQ,UAAU;AAC1C,UAAM,EAAE,QAAQ,IAAI,MAAM,KAAK,eAA+C,gBAAgB,IAAI,EAAE;AACpG,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,QAAQ,YAAoB;AACzC,UAAM,SAAS,KAAK,OAAO,UAAU;AAErC,QAAI,CAAC,QAAQ;AACZ,YAAM,OAAO,MAAM,KAAK,QAAQ,UAAU;AAC1C,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR;AACD;","names":["key","args","messages"]} \ No newline at end of file diff --git a/dist/cjs/lib/managers/ResourceManager.d.ts b/dist/cjs/lib/managers/ResourceManager.d.ts new file mode 100644 index 0000000..3ea801e --- /dev/null +++ b/dist/cjs/lib/managers/ResourceManager.d.ts @@ -0,0 +1,2 @@ +export { ResourceManager } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/managers/ResourceManager.js b/dist/cjs/lib/managers/ResourceManager.js new file mode 100644 index 0000000..b4d1bc8 --- /dev/null +++ b/dist/cjs/lib/managers/ResourceManager.js @@ -0,0 +1,112 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/managers/ResourceManager.ts +var ResourceManager_exports = {}; +__export(ResourceManager_exports, { + ResourceManager: () => ResourceManager +}); +module.exports = __toCommonJS(ResourceManager_exports); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; + +// src/lib/managers/ResourceManager.ts +var ResourceManager = class extends BaseManager { + static { + __name(this, "ResourceManager"); + } + constructor(client) { + super(client, false); + } + /** + * Fetch information about Hypixel games + */ + async fetchGameInformation() { + return this.makeGetRequest("/resources/games"); + } + /** + * Fetch all achievements + */ + async fetchAchievements() { + return this.makeGetRequest("/resources/achievements"); + } + /** + * Fetch all challenges + */ + async fetchChallenges() { + return this.makeGetRequest("/resources/challenges"); + } + /** + * Fetch all quests + */ + async fetchQuests() { + return this.makeGetRequest("/resources/quests"); + } + /** + * Fetch all guild achievements + */ + async fetchGuildAchievements() { + return this.makeGetRequest("/resources/guilds/achievements"); + } + /** + * Fetch all vanity pets + */ + async fetchVanityPets() { + return this.makeGetRequest("/resources/vanity/pets"); + } + /** + * Fetch all vanity companions + */ + async fetchVanityCompanions() { + return this.makeGetRequest("/resources/vanity/companions"); + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + ResourceManager +}); +//# sourceMappingURL=ResourceManager.js.map \ No newline at end of file diff --git a/dist/cjs/lib/managers/ResourceManager.js.map b/dist/cjs/lib/managers/ResourceManager.js.map new file mode 100644 index 0000000..bcc6198 --- /dev/null +++ b/dist/cjs/lib/managers/ResourceManager.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/ResourceManager.ts","../../../../src/lib/managers/BaseManager.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport type { Client } from '../Client';\r\nimport type {\r\n\tVanityPetsResponse,\r\n\tAchievementsResponse,\r\n\tChallengesResponse,\r\n\tGameInformationResponse,\r\n\tGuildAchievementsResponse,\r\n\tQuestsResponse,\r\n\tVanityCompanionsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Resource endpoints.\r\n *\r\n * **Note**: API Key authorization is not required to use this manager.\r\n *\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class ResourceManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, false);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information about Hypixel games\r\n\t */\r\n\tpublic async fetchGameInformation() {\r\n\t\treturn this.makeGetRequest('/resources/games');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all achievements\r\n\t */\r\n\tpublic async fetchAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all challenges\r\n\t */\r\n\tpublic async fetchChallenges() {\r\n\t\treturn this.makeGetRequest('/resources/challenges');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all quests\r\n\t */\r\n\tpublic async fetchQuests() {\r\n\t\treturn this.makeGetRequest('/resources/quests');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all guild achievements\r\n\t */\r\n\tpublic async fetchGuildAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/guilds/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity pets\r\n\t */\r\n\tpublic async fetchVanityPets() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/pets');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity companions\r\n\t */\r\n\tpublic async fetchVanityCompanions() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/companions');\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,cAAN,MAAkB;AAAA,EAPzB,OAOyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAId;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEH,YAAY,QAAgB,cAAuB;AACzD,SAAK,SAAS;AACd,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAgB,eAAkB,MAAc;AAC/C,WAAO,KAAK,OAAO,SAAS,QAAW,MAAM,KAAK,YAAY;AAAA,EAC/D;AACD;;;ADbO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EApBjD,OAoBiD;AAAA;AAAA;AAAA,EACzC,YAAY,QAAgB;AAClC,UAAM,QAAQ,KAAK;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,uBAAuB;AACnC,WAAO,KAAK,eAAwC,kBAAkB;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,oBAAoB;AAChC,WAAO,KAAK,eAAqC,yBAAyB;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,kBAAkB;AAC9B,WAAO,KAAK,eAAmC,uBAAuB;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,cAAc;AAC1B,WAAO,KAAK,eAA+B,mBAAmB;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,yBAAyB;AACrC,WAAO,KAAK,eAA0C,gCAAgC;AAAA,EACvF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,kBAAkB;AAC9B,WAAO,KAAK,eAAmC,wBAAwB;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,wBAAwB;AACpC,WAAO,KAAK,eAAyC,8BAA8B;AAAA,EACpF;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/managers/SkyBlockManager.d.ts b/dist/cjs/lib/managers/SkyBlockManager.d.ts new file mode 100644 index 0000000..bacbbcb --- /dev/null +++ b/dist/cjs/lib/managers/SkyBlockManager.d.ts @@ -0,0 +1,2 @@ +export { SkyBlockManager } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/managers/SkyBlockManager.js b/dist/cjs/lib/managers/SkyBlockManager.js new file mode 100644 index 0000000..0f21800 --- /dev/null +++ b/dist/cjs/lib/managers/SkyBlockManager.js @@ -0,0 +1,365 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/managers/SkyBlockManager.ts +var SkyBlockManager_exports = {}; +__export(SkyBlockManager_exports, { + SkyBlockManager: () => SkyBlockManager +}); +module.exports = __toCommonJS(SkyBlockManager_exports); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/SkyBlockAuction.ts +var SkyBlockAuction = class extends Base { + static { + __name(this, "SkyBlockAuction"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client, data) { + super(client); + if ("_id" in data) + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockProfile.ts +var SkyBlockProfile = class extends Base { + static { + __name(this, "SkyBlockProfile"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockMuseum.ts +var SkyBlockMuseum = class extends Base { + static { + __name(this, "SkyBlockMuseum"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/managers/SkyBlockManager.ts +var SkyBlockManager = class extends BaseManager { + static { + __name(this, "SkyBlockManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch information regarding collections in the SkyBlock game + */ + async fetchCollections() { + const data = await this.makeGetRequest("/resources/skyblock/collections"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections + }; + } + /** + * Fetch information regarding skills in the SkyBlock game + */ + async fetchSkills() { + const data = await this.makeGetRequest("/resources/skyblock/skills"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections, + skills: data.skills + }; + } + /** + * Fetch information regarding items in the SkyBlock game + */ + async fetchItems() { + const data = await this.makeGetRequest("/resources/skyblock/items"); + return { + lastUpdated: data.lastUpdated, + items: data.items + }; + } + /** + * Fetch information regarding the current mayor and ongoing election in SkyBlock + */ + async fetchElectionAndMayor() { + const data = await this.makeGetRequest("/resources/skyblock/election"); + return { + lastUpdated: data.lastUpdated, + mayor: data.mayor, + current: data.current + }; + } + /** + * Fetch information regarding the current bingo event and its goals + */ + async fetchActiveBingoGoals() { + const data = await this.makeGetRequest("/resources/skyblock/bingo"); + return { + lastUpdated: data.lastUpdated, + id: data.id, + goals: data.goals + }; + } + /** + * Fetch SkyBlock news + */ + async fetchNews() { + const data = await this.makeGetRequest("/skyblock/news"); + return { + items: data.items + }; + } + /** + * Fetch a SkyBlock auction. + * @param identifier The idenitifer you're using to fetch the auction + * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`) + * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`. + */ + async fetchAuction(identifier, type, raw = false) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "type"); + if (type !== "uuid" && type !== "player" && type !== "profile") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchAuction", "type", ["uuid", "player", "profile"]); + const { auctions } = await this.makeGetRequest(`/skyblock/auction?${type}=${identifier}`); + if (!raw) { + const parsed = []; + for (const auction of auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return parsed; + } + return auctions; + } + /** + * Fetch the currently active auctions (sorted by last updated first and paginated) + * @param page The page number + * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`. + */ + async fetchActiveAuctions(page, resolveAuctions = true) { + if (page && typeof page !== "number") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchActiveAuctions", "page", ["number"]); + const data = await this.makeGetRequest(`/skyblock/auctions${page ? "?page=" + page : ""}`); + if (resolveAuctions) { + const parsed = []; + for (const auction of data.auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: parsed + }; + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: data.auctions + }; + } + /** + * Fetch recently ended auctions (auctions which ended in the last 60 seconds). + */ + async fetchRecentlyEndedAuctions() { + const data = await this.makeGetRequest("/skyblock/auctions_ended"); + return { + lastUpdated: data.lastUpdated, + auctions: data.auctions + }; + } + /** + * Fetch bazaar items + */ + async fetchBazaar() { + const data = await this.makeGetRequest("/skyblock/bazaar"); + return { + lastUpdated: data.lastUpdated, + products: data.products + }; + } + /** + * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchProfile(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchProfile", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`); + return new SkyBlockProfile(this.client, data); + } + /** + * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchMuseum(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchMuseum", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`); + return new SkyBlockMuseum(this.client, data); + } + /** + * Fetch a SkyBlock profiles of a player + * @param playerUuid The uuid of the player + */ + async fetchPlayerSkyBlockProfiles(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchPlayerSkyBlockProfiles", "playerUuid"); + const { profiles } = await this.makeGetRequest(`/skyblock/profiles?uuid=${playerUuid}`); + const parsed = []; + for (const profile of profiles) { + parsed.push(new SkyBlockProfile(this.client, profile)); + } + return parsed; + } + /** + * Fetch bingo data of a player + * @param playerUuid The uuid of the player + */ + async fetchBingoData(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchBingoData", "playerUuid"); + const data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`); + return { + events: data.events + }; + } + /** + * Fetch the currently active or upcoming Fire Sales for SkyBlock + */ + async fetchFireSales() { + const { sales } = await this.makeGetRequest("/skyblock/firesales"); + return sales; + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + SkyBlockManager +}); +//# sourceMappingURL=SkyBlockManager.js.map \ No newline at end of file diff --git a/dist/cjs/lib/managers/SkyBlockManager.js.map b/dist/cjs/lib/managers/SkyBlockManager.js.map new file mode 100644 index 0000000..0885c5f --- /dev/null +++ b/dist/cjs/lib/managers/SkyBlockManager.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/SkyBlockManager.ts","../../../../src/lib/managers/BaseManager.ts","../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/errors/Messages.ts","../../../../src/lib/classes/Base.ts","../../../../src/lib/classes/SkyBlockAuction.ts","../../../../src/lib/classes/SkyBlockProfile.ts","../../../../src/lib/classes/SkyBlockMuseum.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport { SkyBlockProfile, SkyBlockAuction, SkyBlockMuseum } from '../classes/index';\r\nimport type { Client } from '../Client';\r\nimport {\r\n\ttype APISkyBlockProfile,\r\n\ttype FetchCollectionsResponse,\r\n\ttype FetchSkillsResponse,\r\n\ttype FetchItemsResponse,\r\n\ttype FetchElectionAndMayorResponse,\r\n\ttype FetchActiveBingoGoalsResponse,\r\n\ttype FetchNewsResponse,\r\n\ttype APISkyBlockAuction,\r\n\ttype FetchActiveAuctionsResponse,\r\n\ttype FetchBazaarResponse,\r\n\ttype RecentlyEndedAuctionsResponse,\r\n\ttype FetchBingoDataResponse,\r\n\ttype FetchFireSalesResponse,\r\n\ttype FetchFireSalesResponseFireSale,\r\n\tAPISkyBlockMuseum\r\n} from '../typings';\r\n\r\n/**\r\n * Skyblock related endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock}\r\n */\r\nexport class SkyBlockManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding collections in the SkyBlock game\r\n\t */\r\n\tpublic async fetchCollections(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/collections');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding skills in the SkyBlock game\r\n\t */\r\n\tpublic async fetchSkills(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/skills');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections,\r\n\t\t\tskills: data.skills\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding items in the SkyBlock game\r\n\t */\r\n\tpublic async fetchItems(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/items');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current mayor and ongoing election in SkyBlock\r\n\t */\r\n\tpublic async fetchElectionAndMayor(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/election');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tmayor: data.mayor,\r\n\t\t\tcurrent: data.current\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current bingo event and its goals\r\n\t */\r\n\tpublic async fetchActiveBingoGoals(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/bingo');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tid: data.id,\r\n\t\t\tgoals: data.goals\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch SkyBlock news\r\n\t */\r\n\tpublic async fetchNews() {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/news');\r\n\t\treturn {\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock auction.\r\n\t * @param identifier The idenitifer you're using to fetch the auction\r\n\t * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`)\r\n\t * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`.\r\n\t */\r\n\tpublic async fetchAuction(\r\n\t\tidentifier: string,\r\n\t\ttype: 'uuid' | 'player' | 'profile',\r\n\t\traw = false\r\n\t): Promise {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'type');\r\n\t\tif (type !== 'uuid' && type !== 'player' && type !== 'profile')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchAuction', 'type', ['uuid', 'player', 'profile']);\r\n\r\n\t\tconst { auctions } = await this.makeGetRequest<{ auctions: APISkyBlockAuction[] }>(`/skyblock/auction?${type}=${identifier}`);\r\n\r\n\t\tif (!raw) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn parsed;\r\n\t\t}\r\n\r\n\t\treturn auctions;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active auctions (sorted by last updated first and paginated)\r\n\t * @param page The page number\r\n\t * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`.\r\n\t */\r\n\tpublic async fetchActiveAuctions(page?: number, resolveAuctions = true) {\r\n\t\tif (page && typeof page !== 'number')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchActiveAuctions', 'page', ['number']);\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/auctions${page ? '?page=' + page : ''}`);\r\n\r\n\t\tif (resolveAuctions) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of data.auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn {\r\n\t\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\t\tpage: data.page,\r\n\t\t\t\ttotalPages: data.totalPages,\r\n\t\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\t\tauctions: parsed\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tpage: data.page,\r\n\t\t\ttotalPages: data.totalPages,\r\n\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch recently ended auctions (auctions which ended in the last 60 seconds).\r\n\t */\r\n\tpublic async fetchRecentlyEndedAuctions(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/auctions_ended');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bazaar items\r\n\t */\r\n\tpublic async fetchBazaar(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/bazaar');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tproducts: data.products\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchProfile(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchProfile', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockProfile(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchMuseum(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchMuseum', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockMuseum(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profiles of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchPlayerSkyBlockProfiles(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchPlayerSkyBlockProfiles', 'playerUuid');\r\n\r\n\t\tconst { profiles } = await this.makeGetRequest<{ profiles: APISkyBlockProfile[] }>(`/skyblock/profiles?uuid=${playerUuid}`);\r\n\t\tconst parsed = [];\r\n\r\n\t\tfor (const profile of profiles) {\r\n\t\t\tparsed.push(new SkyBlockProfile(this.client, profile));\r\n\t\t}\r\n\r\n\t\treturn parsed;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bingo data of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchBingoData(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchBingoData', 'playerUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`);\r\n\t\treturn {\r\n\t\t\tevents: data.events\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active or upcoming Fire Sales for SkyBlock\r\n\t */\r\n\tpublic async fetchFireSales(): Promise {\r\n\t\tconst { sales } = await this.makeGetRequest('/skyblock/firesales');\r\n\t\treturn sales;\r\n\t}\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockAuction } from '../typings';\r\n\r\nexport interface SkyBlockAuction extends APISkyBlockAuction {}\r\n/**\r\n * The sky block auction class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get}\r\n */\r\nexport class SkyBlockAuction extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock auction data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockAuction) {\r\n\t\tsuper(client);\r\n\t\tif ('_id' in data) data.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockProfile } from '../typings';\r\n\r\nexport interface SkyBlockProfile extends APISkyBlockProfile {}\r\n/**\r\n * The SkyBlockProfile class.\r\n * @category Classes\r\n * @Group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get}\r\n */\r\nexport class SkyBlockProfile extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockProfile) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockMuseum } from '../typings';\r\n\r\nexport interface SkyBlockMuseum extends APISkyBlockMuseum {}\r\n/**\r\n * The SkyBlockMuseum class.\r\n * @category Classes\r\n * @Group Classes\r\n */\r\nexport class SkyBlockMuseum extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockMuseum) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,cAAN,MAAkB;AAAA,EAPzB,OAOyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAId;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEH,YAAY,QAAgB,cAAuB;AACzD,SAAK,SAAS;AACd,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAgB,eAAkB,MAAc;AAC/C,WAAO,KAAK,OAAO,SAAS,QAAW,MAAM,KAAK,YAAY;AAAA,EAC/D;AACD;;;AC/BA,IAAM,WAAW,oBAAI,IAA2C;AAEzD,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAJ1C,OAI0C;AAAA;AAAA;AAAA,EAClC,YAAY,QAAgB,MAAa;AAC/C,UAAM,WAAW,KAAK,IAAI,CAAC;AAE3B,aAAS,WAAWA,MAAaC,OAAa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at end of file diff --git a/dist/cjs/lib/managers/index.d.ts b/dist/cjs/lib/managers/index.d.ts new file mode 100644 index 0000000..0b5aa68 --- /dev/null +++ b/dist/cjs/lib/managers/index.d.ts @@ -0,0 +1,2 @@ +export { BaseManager, GuildManager, OtherManager, PlayerManager, ResourceManager, SkyBlockManager } from '../../index.js'; +import '../rest/HypixelAPIError.js'; diff --git a/dist/cjs/lib/managers/index.js b/dist/cjs/lib/managers/index.js new file mode 100644 index 0000000..eb5b3f3 --- /dev/null +++ b/dist/cjs/lib/managers/index.js @@ -0,0 +1,646 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/managers/index.ts +var managers_exports = {}; +__export(managers_exports, { + BaseManager: () => BaseManager, + GuildManager: () => GuildManager, + OtherManager: () => OtherManager, + PlayerManager: () => PlayerManager, + ResourceManager: () => ResourceManager, + SkyBlockManager: () => SkyBlockManager +}); +module.exports = __toCommonJS(managers_exports); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; + +// src/lib/classes/Guild.ts +var Guild = class extends Base { + static { + __name(this, "Guild"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client, data) { + super(client); + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/managers/GuildManager.ts +var GuildManager = class extends BaseManager { + static { + __name(this, "GuildManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid + * @param identifier The id/name of the guild or the uuid of the player + * @param type The type of identifier you're passing (id/name of guild, player uuid) + */ + async fetch(identifier, type) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "type"); + if (type !== "id" && type !== "name" && type !== "player") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "GuildManager", "fetch", "type", ["id", "name", "player"]); + const { guild } = await this.makeGetRequest(`/guild?${type}=${identifier}`); + return guild ? new Guild(this.client, guild) : null; + } +}; + +// src/lib/managers/OtherManager.ts +var OtherManager = class extends BaseManager { + static { + __name(this, "OtherManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch all active network boosters + */ + async fetchActiveNetworkBoosters() { + const data = await this.makeGetRequest("/boosters"); + return { + boosters: data.boosters, + boosterState: data.boosterState + }; + } + /** + * Fetch current player counts across all games + */ + async fetchCurrentPlayerCounts() { + const data = await this.makeGetRequest("/counts"); + return { + playerCount: data.playerCount, + games: data.games + }; + } + /** + * Fetch current leaderboards + */ + async fetchCurrentLeaderboards() { + const data = await this.makeGetRequest("/leaderboards"); + return { + leaderboards: data.leaderboards + }; + } + /** + * Fetch punishment statistics + */ + async fetchPunishmentStatistics() { + const data = await this.makeGetRequest("/punishmentstats"); + return { + watchdog_lastMinute: data.watchdog_lastMinute, + staff_rollingDaily: data.staff_rollingDaily, + watchdog_total: data.watchdog_total, + watchdog_rollingDaily: data.watchdog_rollingDaily, + staff_total: data.staff_total + }; + } +}; + +// src/lib/classes/Player.ts +var Player = class extends Base { + static { + __name(this, "Player"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + async fetchSkyBlockProfiles() { + return this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid); + } +}; + +// src/lib/classes/SkyBlockAuction.ts +var SkyBlockAuction = class extends Base { + static { + __name(this, "SkyBlockAuction"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client, data) { + super(client); + if ("_id" in data) + data.id = data._id; + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockProfile.ts +var SkyBlockProfile = class extends Base { + static { + __name(this, "SkyBlockProfile"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/SkyBlockMuseum.ts +var SkyBlockMuseum = class extends Base { + static { + __name(this, "SkyBlockMuseum"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; + +// src/lib/classes/Util.ts +var Util = class extends Base { + static { + __name(this, "Util"); + } + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static async getUUID(name) { + try { + const data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_UUID_ERROR", json.errorMessage, data.status); + return json.id; + } catch { + throw new HypixelTSError("GET_UUID_404"); + } + } + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static async getUsername(uuid) { + if (!this.isUUID(uuid)) { + throw new HypixelTSError("NOT_UUID"); + } + try { + const data = await fetch(`https://api.mojang.com/user/profile/${uuid}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_USERNAME_ERROR", json.errorMessage, data.status); + return json.name; + } catch { + throw new HypixelTSError("GET_USERNAME_404"); + } + } + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid) { + const regexStripped = /^[0-9a-f]{32}$/i; + const regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}$/i; + return regexStripped.test(uuid) || regexFull.test(uuid); + } +}; + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); + +// src/lib/managers/PlayerManager.ts +var PlayerManager = class extends BaseManager { + static { + __name(this, "PlayerManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a player using their username or uuid + * @param identifier The username/uuid of the player + */ + async fetch(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "fetch", "identifier"); + const uuid = await this.getUUID(identifier); + const { player } = await this.makeGetRequest(`/player?uuid=${uuid}`); + return new Player(this.client, player); + } + /** + * Fetch the recently played games of a player + * @param identifier The username/uuid of the player + */ + async getRecentlyPlayedGames(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getRecentlyPlayedGames", "identifier"); + const uuid = await this.getUUID(identifier); + const { games } = await this.makeGetRequest(`/recentgames?uuid=${uuid}`); + return games; + } + /** + * Fetch the status of a player + * @param identifier The username/uuid of the player + */ + async getStatus(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getStatus", "identifier"); + const uuid = await this.getUUID(identifier); + const { session } = await this.makeGetRequest(`/status?uuid=${uuid}`); + return session; + } + /** + * Resolves the username to a uuid for use in requests + * @param identifier The username (or uuid) of the player + */ + async getUUID(identifier) { + const isUUID = Util.isUUID(identifier); + if (!isUUID) { + const uuid = await Util.getUUID(identifier); + return uuid; + } + return identifier; + } +}; + +// src/lib/managers/ResourceManager.ts +var ResourceManager = class extends BaseManager { + static { + __name(this, "ResourceManager"); + } + constructor(client) { + super(client, false); + } + /** + * Fetch information about Hypixel games + */ + async fetchGameInformation() { + return this.makeGetRequest("/resources/games"); + } + /** + * Fetch all achievements + */ + async fetchAchievements() { + return this.makeGetRequest("/resources/achievements"); + } + /** + * Fetch all challenges + */ + async fetchChallenges() { + return this.makeGetRequest("/resources/challenges"); + } + /** + * Fetch all quests + */ + async fetchQuests() { + return this.makeGetRequest("/resources/quests"); + } + /** + * Fetch all guild achievements + */ + async fetchGuildAchievements() { + return this.makeGetRequest("/resources/guilds/achievements"); + } + /** + * Fetch all vanity pets + */ + async fetchVanityPets() { + return this.makeGetRequest("/resources/vanity/pets"); + } + /** + * Fetch all vanity companions + */ + async fetchVanityCompanions() { + return this.makeGetRequest("/resources/vanity/companions"); + } +}; + +// src/lib/managers/SkyBlockManager.ts +var SkyBlockManager = class extends BaseManager { + static { + __name(this, "SkyBlockManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch information regarding collections in the SkyBlock game + */ + async fetchCollections() { + const data = await this.makeGetRequest("/resources/skyblock/collections"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections + }; + } + /** + * Fetch information regarding skills in the SkyBlock game + */ + async fetchSkills() { + const data = await this.makeGetRequest("/resources/skyblock/skills"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections, + skills: data.skills + }; + } + /** + * Fetch information regarding items in the SkyBlock game + */ + async fetchItems() { + const data = await this.makeGetRequest("/resources/skyblock/items"); + return { + lastUpdated: data.lastUpdated, + items: data.items + }; + } + /** + * Fetch information regarding the current mayor and ongoing election in SkyBlock + */ + async fetchElectionAndMayor() { + const data = await this.makeGetRequest("/resources/skyblock/election"); + return { + lastUpdated: data.lastUpdated, + mayor: data.mayor, + current: data.current + }; + } + /** + * Fetch information regarding the current bingo event and its goals + */ + async fetchActiveBingoGoals() { + const data = await this.makeGetRequest("/resources/skyblock/bingo"); + return { + lastUpdated: data.lastUpdated, + id: data.id, + goals: data.goals + }; + } + /** + * Fetch SkyBlock news + */ + async fetchNews() { + const data = await this.makeGetRequest("/skyblock/news"); + return { + items: data.items + }; + } + /** + * Fetch a SkyBlock auction. + * @param identifier The idenitifer you're using to fetch the auction + * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`) + * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`. + */ + async fetchAuction(identifier, type, raw = false) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "type"); + if (type !== "uuid" && type !== "player" && type !== "profile") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchAuction", "type", ["uuid", "player", "profile"]); + const { auctions } = await this.makeGetRequest(`/skyblock/auction?${type}=${identifier}`); + if (!raw) { + const parsed = []; + for (const auction of auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return parsed; + } + return auctions; + } + /** + * Fetch the currently active auctions (sorted by last updated first and paginated) + * @param page The page number + * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`. + */ + async fetchActiveAuctions(page, resolveAuctions = true) { + if (page && typeof page !== "number") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchActiveAuctions", "page", ["number"]); + const data = await this.makeGetRequest(`/skyblock/auctions${page ? "?page=" + page : ""}`); + if (resolveAuctions) { + const parsed = []; + for (const auction of data.auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: parsed + }; + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: data.auctions + }; + } + /** + * Fetch recently ended auctions (auctions which ended in the last 60 seconds). + */ + async fetchRecentlyEndedAuctions() { + const data = await this.makeGetRequest("/skyblock/auctions_ended"); + return { + lastUpdated: data.lastUpdated, + auctions: data.auctions + }; + } + /** + * Fetch bazaar items + */ + async fetchBazaar() { + const data = await this.makeGetRequest("/skyblock/bazaar"); + return { + lastUpdated: data.lastUpdated, + products: data.products + }; + } + /** + * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchProfile(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchProfile", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`); + return new SkyBlockProfile(this.client, data); + } + /** + * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchMuseum(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchMuseum", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`); + return new SkyBlockMuseum(this.client, data); + } + /** + * Fetch a SkyBlock profiles of a player + * @param playerUuid The uuid of the player + */ + async fetchPlayerSkyBlockProfiles(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchPlayerSkyBlockProfiles", "playerUuid"); + const { profiles } = await this.makeGetRequest(`/skyblock/profiles?uuid=${playerUuid}`); + const parsed = []; + for (const profile of profiles) { + parsed.push(new SkyBlockProfile(this.client, profile)); + } + return parsed; + } + /** + * Fetch bingo data of a player + * @param playerUuid The uuid of the player + */ + async fetchBingoData(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchBingoData", "playerUuid"); + const data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`); + return { + events: data.events + }; + } + /** + * Fetch the currently active or upcoming Fire Sales for SkyBlock + */ + async fetchFireSales() { + const { sales } = await this.makeGetRequest("/skyblock/firesales"); + return sales; + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + BaseManager, + GuildManager, + OtherManager, + PlayerManager, + ResourceManager, + SkyBlockManager +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/cjs/lib/managers/index.js.map b/dist/cjs/lib/managers/index.js.map new file mode 100644 index 0000000..5e2e8a4 --- /dev/null +++ b/dist/cjs/lib/managers/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/index.ts","../../../../src/lib/managers/BaseManager.ts","../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/classes/Base.ts","../../../../src/lib/classes/Guild.ts","../../../../src/lib/managers/GuildManager.ts","../../../../src/lib/managers/OtherManager.ts","../../../../src/lib/classes/Player.ts","../../../../src/lib/classes/SkyBlockAuction.ts","../../../../src/lib/classes/SkyBlockProfile.ts","../../../../src/lib/classes/SkyBlockMuseum.ts","../../../../src/lib/classes/Util.ts","../../../../src/lib/errors/Messages.ts","../../../../src/lib/managers/PlayerManager.ts","../../../../src/lib/managers/ResourceManager.ts","../../../../src/lib/managers/SkyBlockManager.ts"],"sourcesContent":["export * from './BaseManager';\r\n\r\nexport * from './GuildManager';\r\nexport * from './OtherManager';\r\nexport * from './PlayerManager';\r\nexport * from './ResourceManager';\r\nexport * from './SkyBlockManager';\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APIGuild } from '../typings';\r\n\r\n/**\r\n * The guild class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get}\r\n */\r\nexport class Guild extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Guild data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIGuild) {\r\n\t\tsuper(client);\r\n\t\tdata.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport { Guild } from '../classes/Guild';\r\nimport type { APIGuild } from '../typings';\r\nimport type { Client } from '../Client';\r\n\r\n/**\r\n * Guild related endpoints\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class GuildManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid\r\n\t * @param identifier The id/name of the guild or the uuid of the player\r\n\t * @param type The type of identifier you're passing (id/name of guild, player uuid)\r\n\t */\r\n\tpublic async fetch(identifier: string, type: 'id' | 'name' | 'player') {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'type');\r\n\t\tif (type !== 'id' && type !== 'name' && type !== 'player')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'GuildManager', 'fetch', 'type', ['id', 'name', 'player']);\r\n\r\n\t\tconst { guild } = await this.makeGetRequest<{ guild: APIGuild | null }>(`/guild?${type}=${identifier}`);\r\n\t\treturn guild ? new Guild(this.client, guild) : null;\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport type {\r\n\tActiveNetworkBoostersResponse,\r\n\tCurrentPlayerCountsResponse,\r\n\tCurrentLeaderboardsResponse,\r\n\tPunishmentStatisticsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Other endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/Other}\r\n */\r\nexport class OtherManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all active network boosters\r\n\t */\r\n\tpublic async fetchActiveNetworkBoosters(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/boosters');\r\n\t\treturn {\r\n\t\t\tboosters: data.boosters,\r\n\t\t\tboosterState: data.boosterState\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current player counts across all games\r\n\t */\r\n\tpublic async fetchCurrentPlayerCounts(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/counts');\r\n\t\treturn {\r\n\t\t\tplayerCount: data.playerCount,\r\n\t\t\tgames: data.games\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current leaderboards\r\n\t */\r\n\tpublic async fetchCurrentLeaderboards(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/leaderboards');\r\n\t\treturn {\r\n\t\t\tleaderboards: data.leaderboards\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch punishment statistics\r\n\t */\r\n\tpublic async fetchPunishmentStatistics(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/punishmentstats');\r\n\t\treturn {\r\n\t\t\twatchdog_lastMinute: data.watchdog_lastMinute,\r\n\t\t\tstaff_rollingDaily: data.staff_rollingDaily,\r\n\t\t\twatchdog_total: data.watchdog_total,\r\n\t\t\twatchdog_rollingDaily: data.watchdog_rollingDaily,\r\n\t\t\tstaff_total: data.staff_total\r\n\t\t};\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { Client } from '../Client';\r\nimport { APIPlayer } from '../typings';\r\n\r\nexport interface Player extends APIPlayer {}\r\n/**\r\n * The player class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get}\r\n */\r\nexport class Player extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Player data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIPlayer) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the SkyBlock profiles of this player\r\n\t * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles}\r\n\t */\r\n\tpublic async fetchSkyBlockProfiles() {\r\n\t\treturn this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockAuction } from '../typings';\r\n\r\nexport interface SkyBlockAuction extends APISkyBlockAuction {}\r\n/**\r\n * The sky block auction class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get}\r\n */\r\nexport class SkyBlockAuction extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock auction data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockAuction) {\r\n\t\tsuper(client);\r\n\t\tif ('_id' in data) data.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockProfile } from '../typings';\r\n\r\nexport interface SkyBlockProfile extends APISkyBlockProfile {}\r\n/**\r\n * The SkyBlockProfile class.\r\n * @category Classes\r\n * @Group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get}\r\n */\r\nexport class SkyBlockProfile extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockProfile) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockMuseum } from '../typings';\r\n\r\nexport interface SkyBlockMuseum extends APISkyBlockMuseum {}\r\n/**\r\n * The SkyBlockMuseum class.\r\n * @category Classes\r\n * @Group Classes\r\n */\r\nexport class SkyBlockMuseum extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockMuseum) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n","import { Base } from './Base';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport type { GetUsernameResponse, GetUUIDResponse } from '../typings';\r\n\r\n/**\r\n * Utility functions\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Util extends Base {\r\n\t/**\r\n\t * Get the UUID of a player by providing their name\r\n\t * @param name The name of the player\r\n\t */\r\n\tpublic static async getUUID(name: string): Promise {\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`);\r\n\t\t\tconst json = (await data.json()) as GetUUIDResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_UUID_ERROR', json.errorMessage, data.status);\r\n\t\t\treturn json.id;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_UUID_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Get player's name from their UUID\r\n\t * @param uuid The uuid of the player\r\n\t */\r\n\tpublic static async getUsername(uuid: string): Promise {\r\n\t\tif (!this.isUUID(uuid)) {\r\n\t\t\tthrow new HypixelTSError('NOT_UUID');\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/user/profile/${uuid}`);\r\n\t\t\tconst json = (await data.json()) as GetUsernameResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_USERNAME_ERROR', json.errorMessage, data.status);\r\n\r\n\t\t\treturn json.name;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_USERNAME_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Check whether the provided UUID is a valid UUID or not\r\n\t * @param uuid The UUID to check\r\n\t */\r\n\tpublic static isUUID(uuid: string) {\r\n\t\tconst regexStripped = /^[0-9a-f]{32}$/i;\r\n\t\tconst regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}$/i;\r\n\t\treturn regexStripped.test(uuid) || regexFull.test(uuid);\r\n\t}\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n","import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport { Player, Util } from '../classes/index';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport type { APIPlayer, GetRecentlyPlayedGamesResponse, GetStatusResponse } from '../typings';\r\n\r\n/**\r\n * Player related endpoints.\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class PlayerManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a player using their username or uuid\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async fetch(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'fetch', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { player } = await this.makeGetRequest<{ player: APIPlayer }>(`/player?uuid=${uuid}`);\r\n\t\treturn new Player(this.client, player);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the recently played games of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getRecentlyPlayedGames(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getRecentlyPlayedGames', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { games } = await this.makeGetRequest<{ games: GetRecentlyPlayedGamesResponse[] }>(`/recentgames?uuid=${uuid}`);\r\n\t\treturn games;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the status of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getStatus(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getStatus', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { session } = await this.makeGetRequest<{ session: GetStatusResponse }>(`/status?uuid=${uuid}`);\r\n\t\treturn session;\r\n\t}\r\n\r\n\t/**\r\n\t * Resolves the username to a uuid for use in requests\r\n\t * @param identifier The username (or uuid) of the player\r\n\t */\r\n\tprivate async getUUID(identifier: string) {\r\n\t\tconst isUUID = Util.isUUID(identifier);\r\n\r\n\t\tif (!isUUID) {\r\n\t\t\tconst uuid = await Util.getUUID(identifier);\r\n\t\t\treturn uuid;\r\n\t\t}\r\n\r\n\t\treturn identifier;\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport type { Client } from '../Client';\r\nimport type {\r\n\tVanityPetsResponse,\r\n\tAchievementsResponse,\r\n\tChallengesResponse,\r\n\tGameInformationResponse,\r\n\tGuildAchievementsResponse,\r\n\tQuestsResponse,\r\n\tVanityCompanionsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Resource endpoints.\r\n *\r\n * **Note**: API Key authorization is not required to use this manager.\r\n *\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class ResourceManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, false);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information about Hypixel games\r\n\t */\r\n\tpublic async fetchGameInformation() {\r\n\t\treturn this.makeGetRequest('/resources/games');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all achievements\r\n\t */\r\n\tpublic async fetchAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all challenges\r\n\t */\r\n\tpublic async fetchChallenges() {\r\n\t\treturn this.makeGetRequest('/resources/challenges');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all quests\r\n\t */\r\n\tpublic async fetchQuests() {\r\n\t\treturn this.makeGetRequest('/resources/quests');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all guild achievements\r\n\t */\r\n\tpublic async fetchGuildAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/guilds/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity pets\r\n\t */\r\n\tpublic async fetchVanityPets() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/pets');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity companions\r\n\t */\r\n\tpublic async fetchVanityCompanions() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/companions');\r\n\t}\r\n}\r\n","import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport { SkyBlockProfile, SkyBlockAuction, SkyBlockMuseum } from '../classes/index';\r\nimport type { Client } from '../Client';\r\nimport {\r\n\ttype APISkyBlockProfile,\r\n\ttype FetchCollectionsResponse,\r\n\ttype FetchSkillsResponse,\r\n\ttype FetchItemsResponse,\r\n\ttype FetchElectionAndMayorResponse,\r\n\ttype FetchActiveBingoGoalsResponse,\r\n\ttype FetchNewsResponse,\r\n\ttype APISkyBlockAuction,\r\n\ttype FetchActiveAuctionsResponse,\r\n\ttype FetchBazaarResponse,\r\n\ttype RecentlyEndedAuctionsResponse,\r\n\ttype FetchBingoDataResponse,\r\n\ttype FetchFireSalesResponse,\r\n\ttype FetchFireSalesResponseFireSale,\r\n\tAPISkyBlockMuseum\r\n} from '../typings';\r\n\r\n/**\r\n * Skyblock related endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock}\r\n */\r\nexport class SkyBlockManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding collections in the SkyBlock game\r\n\t */\r\n\tpublic async fetchCollections(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/collections');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding skills in the SkyBlock game\r\n\t */\r\n\tpublic async fetchSkills(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/skills');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections,\r\n\t\t\tskills: data.skills\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding items in the SkyBlock game\r\n\t */\r\n\tpublic async fetchItems(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/items');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current mayor and ongoing election in SkyBlock\r\n\t */\r\n\tpublic async fetchElectionAndMayor(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/election');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tmayor: data.mayor,\r\n\t\t\tcurrent: data.current\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current bingo event and its goals\r\n\t */\r\n\tpublic async fetchActiveBingoGoals(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/bingo');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tid: data.id,\r\n\t\t\tgoals: data.goals\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch SkyBlock news\r\n\t */\r\n\tpublic async fetchNews() {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/news');\r\n\t\treturn {\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock auction.\r\n\t * @param identifier The idenitifer you're using to fetch the auction\r\n\t * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`)\r\n\t * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`.\r\n\t */\r\n\tpublic async fetchAuction(\r\n\t\tidentifier: string,\r\n\t\ttype: 'uuid' | 'player' | 'profile',\r\n\t\traw = false\r\n\t): Promise {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'type');\r\n\t\tif (type !== 'uuid' && type !== 'player' && type !== 'profile')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchAuction', 'type', ['uuid', 'player', 'profile']);\r\n\r\n\t\tconst { auctions } = await this.makeGetRequest<{ auctions: APISkyBlockAuction[] }>(`/skyblock/auction?${type}=${identifier}`);\r\n\r\n\t\tif (!raw) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn parsed;\r\n\t\t}\r\n\r\n\t\treturn auctions;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active auctions (sorted by last updated first and paginated)\r\n\t * @param page The page number\r\n\t * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`.\r\n\t */\r\n\tpublic async fetchActiveAuctions(page?: number, resolveAuctions = true) {\r\n\t\tif (page && typeof page !== 'number')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchActiveAuctions', 'page', ['number']);\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/auctions${page ? '?page=' + page : ''}`);\r\n\r\n\t\tif (resolveAuctions) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of data.auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn {\r\n\t\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\t\tpage: data.page,\r\n\t\t\t\ttotalPages: data.totalPages,\r\n\t\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\t\tauctions: parsed\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tpage: data.page,\r\n\t\t\ttotalPages: data.totalPages,\r\n\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch recently ended auctions (auctions which ended in the last 60 seconds).\r\n\t */\r\n\tpublic async fetchRecentlyEndedAuctions(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/auctions_ended');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bazaar items\r\n\t */\r\n\tpublic async fetchBazaar(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/bazaar');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tproducts: data.products\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchProfile(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchProfile', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockProfile(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchMuseum(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchMuseum', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockMuseum(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profiles of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchPlayerSkyBlockProfiles(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchPlayerSkyBlockProfiles', 'playerUuid');\r\n\r\n\t\tconst { profiles } = await this.makeGetRequest<{ profiles: APISkyBlockProfile[] }>(`/skyblock/profiles?uuid=${playerUuid}`);\r\n\t\tconst parsed = [];\r\n\r\n\t\tfor (const profile of profiles) {\r\n\t\t\tparsed.push(new SkyBlockProfile(this.client, profile));\r\n\t\t}\r\n\r\n\t\treturn parsed;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bingo data of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchBingoData(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchBingoData', 'playerUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`);\r\n\t\treturn {\r\n\t\t\tevents: data.events\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active or upcoming Fire Sales for SkyBlock\r\n\t */\r\n\tpublic async fetchFireSales(): Promise {\r\n\t\tconst { sales } = await this.makeGetRequest('/skyblock/firesales');\r\n\t\treturn sales;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,cAAN,MAAkB;AAAA,EAPzB,OAOyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAId;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEH,YAAY,QAAgB,cAAuB;AACzD,SAAK,SAAS;AACd,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAgB,eAAkB,MAAc;AAC/C,WAAO,KAAK,OAAO,S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AAO,MAAM,KAAK,eAAuC,wBAAwB,UAAU,EAAE;AACnG,WAAO;AAAA,MACN,QAAQ,KAAK;AAAA,IACd;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,iBAA4D;AACxE,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,eAAuC,qBAAqB;AACzF,WAAO;AAAA,EACR;AACD;","names":["key","args","messages"]} \ No newline at end of file diff --git a/dist/cjs/lib/rest/ApiRequest.d.ts b/dist/cjs/lib/rest/ApiRequest.d.ts new file mode 100644 index 0000000..dd41b75 --- /dev/null +++ b/dist/cjs/lib/rest/ApiRequest.d.ts @@ -0,0 +1,2 @@ +export { ApiRequest, ApiRequestOptions } from '../../index.js'; +import './HypixelAPIError.js'; diff --git a/dist/cjs/lib/rest/ApiRequest.js b/dist/cjs/lib/rest/ApiRequest.js new file mode 100644 index 0000000..92fea2f --- /dev/null +++ b/dist/cjs/lib/rest/ApiRequest.js @@ -0,0 +1,144 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/rest/ApiRequest.ts +var ApiRequest_exports = {}; +__export(ApiRequest_exports, { + ApiRequest: () => ApiRequest +}); +module.exports = __toCommonJS(ApiRequest_exports); + +// src/lib/rest/HypixelAPIError.ts +var HypixelAPIError = class extends Error { + static { + __name(this, "HypixelAPIError"); + } + code; + constructor(message, code) { + super(message); + this.message = message; + this.code = code; + } +}; + +// src/lib/rest/RequestManager.ts +var import_async_queue = require("@sapphire/async-queue"); + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); + +// src/lib/rest/ApiRequest.ts +var ApiRequest = class { + static { + __name(this, "ApiRequest"); + } + /** + * The request manager instance + */ + requests; + /** + * The options of this request + */ + options; + constructor(requestManager, options) { + this.requests = requestManager; + this.options = options; + } + /** + * Makes a request with the options provided. + */ + async make() { + const options = this.buildOptions(); + const res = await fetch(options.url, { + ...options + }); + if (!res.ok) { + const error = await res.json(); + throw new HypixelAPIError(error?.cause ?? res.statusText, res.status); + } + return res; + } + /** + * Creates an object containing the options to be passed to the request + */ + buildOptions() { + const apiKey = this.requests.client.options?.apiKey; + const headers = { + "Content-Type": "application/json" + }; + if (this.options.sendAPIKey) { + if (!apiKey) + throw new HypixelTSError("CLIENT_OPTIONS_MISSING", "apiKey"); + headers["API-Key"] = apiKey; + } + const options = { + url: `${this.requests.baseApiUrl}${this.options.path}`, + method: this.options.method ?? "GET", + headers + }; + return options; + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + ApiRequest +}); +//# sourceMappingURL=ApiRequest.js.map \ No newline at end of file diff --git a/dist/cjs/lib/rest/ApiRequest.js.map b/dist/cjs/lib/rest/ApiRequest.js.map new file mode 100644 index 0000000..54da8dc --- /dev/null +++ b/dist/cjs/lib/rest/ApiRequest.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/rest/ApiRequest.ts","../../../../src/lib/rest/HypixelAPIError.ts","../../../../src/lib/rest/RequestManager.ts","../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/errors/Messages.ts"],"sourcesContent":["import { RequestManager, HypixelAPIError, type HypixelAPIErrorResponse } from './index';\r\nimport { HypixelTSError } from '../errors/index';\r\n\r\n/**\r\n * The options supplied to the request\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface ApiRequestOptions {\r\n\t/**\r\n\t * The request path/endpoint\r\n\t */\r\n\tpath: string;\r\n\r\n\t/**\r\n\t * The request method, only `GET` is supported\r\n\t */\r\n\tmethod?: 'GET';\r\n\r\n\t/**\r\n\t * Whether to send the API key for this request\r\n\t */\r\n\tsendAPIKey?: boolean;\r\n}\r\n\r\n/**\r\n * Handles (sending/building options) requests\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class ApiRequest {\r\n\t/**\r\n\t * The request manager instance\r\n\t */\r\n\tpublic requests: RequestManager;\r\n\r\n\t/**\r\n\t * The options of this request\r\n\t */\r\n\tpublic options: ApiRequestOptions;\r\n\r\n\tpublic constructor(requestManager: RequestManager, options: ApiRequestOptions) {\r\n\t\tthis.requests = requestManager;\r\n\t\tthis.options = options;\r\n\t}\r\n\r\n\t/**\r\n\t * Makes a request with the options provided.\r\n\t */\r\n\tpublic async make() {\r\n\t\tconst options = this.buildOptions();\r\n\r\n\t\tconst res = await fetch(options.url, {\r\n\t\t\t...options\r\n\t\t});\r\n\r\n\t\tif (!res.ok) {\r\n\t\t\tconst error = (await res.json()) as HypixelAPIErrorResponse;\r\n\t\t\tthrow new HypixelAPIError(error?.cause ?? res.statusText, res.status);\r\n\t\t}\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an object containing the options to be passed to the request\r\n\t */\r\n\tpublic buildOptions() {\r\n\t\tconst apiKey = this.requests.client.options?.apiKey;\r\n\r\n\t\tconst headers: Record = {\r\n\t\t\t'Content-Type': 'application/json'\r\n\t\t};\r\n\r\n\t\tif (this.options.sendAPIKey) {\r\n\t\t\tif (!apiKey) throw new HypixelTSError('CLIENT_OPTIONS_MISSING', 'apiKey');\r\n\t\t\theaders['API-Key'] = apiKey;\r\n\t\t}\r\n\r\n\t\tconst options = {\r\n\t\t\turl: `${this.requests.baseApiUrl}${this.options.path}`,\r\n\t\t\tmethod: this.options.method ?? 'GET',\r\n\t\t\theaders\r\n\t\t};\r\n\r\n\t\treturn options;\r\n\t}\r\n}\r\n","/**\r\n * Response body when an error is returned by the hypixel api\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface HypixelAPIErrorResponse {\r\n\t/**\r\n\t * Whether or not the request is successful\r\n\t */\r\n\tsuccess: boolean;\r\n\r\n\t/**\r\n\t * The message explaining the error\r\n\t */\r\n\tcause: string;\r\n}\r\n\r\n/**\r\n * Error thrown when an error is encountered while querying the hypixel API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class HypixelAPIError extends Error {\r\n\tpublic code: number;\r\n\r\n\tpublic constructor(message: string, code: number) {\r\n\t\tsuper(message);\r\n\t\tthis.message = message;\r\n\t\tthis.code = code;\r\n\t}\r\n}\r\n","import { AsyncQueue } from '@sapphire/async-queue';\r\nimport { ApiRequest } from './ApiRequest';\r\nimport { Client } from '../Client';\r\n\r\n/**\r\n * Manages the requests to the API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class RequestManager {\r\n\t/**\r\n\t * The hypixel.ts client instance\r\n\t */\r\n\tpublic client: Client;\r\n\r\n\t/**\r\n\t * The base url of the hypixel API\r\n\t */\r\n\tpublic baseApiUrl: string;\r\n\r\n\t/**\r\n\t * Queue for requests\r\n\t * @see {@link https://npmjs.com/@sapphire/async-queue}\r\n\t */\r\n\tprivate queue: AsyncQueue;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t\tthis.baseApiUrl = client.options?.baseApiUrl ?? 'https://api.hypixel.net';\r\n\t\tthis.queue = new AsyncQueue();\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the api request and pushes it to the request queue\r\n\t * @param path The path/endpoint to make the request to\r\n\t * @param sendAPIKey Whether or not to send the apiKey with this request\r\n\t */\r\n\tpublic async execute(path: string, sendAPIKey: boolean) {\r\n\t\tawait this.queue.wait();\r\n\t\ttry {\r\n\t\t\tconst request = await new ApiRequest(this, { path, sendAPIKey }).make();\r\n\t\t\treturn request.json() as T;\r\n\t\t} finally {\r\n\t\t\tthis.queue.shift();\r\n\t\t}\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAtB3C,OAsB2C;AAAA;AAAA;AAAA,EACnC;AAAA,EAEA,YAAY,SA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AO;AAAA,EACR;AACD;","names":["key","args","messages"]} \ No newline at end of file diff --git a/dist/cjs/lib/rest/HypixelAPIError.d.ts b/dist/cjs/lib/rest/HypixelAPIError.d.ts new file mode 100644 index 0000000..fc0be38 --- /dev/null +++ b/dist/cjs/lib/rest/HypixelAPIError.d.ts @@ -0,0 +1,26 @@ +/** + * Response body when an error is returned by the hypixel api + * @category Rest + * @group Rest + */ +interface HypixelAPIErrorResponse { + /** + * Whether or not the request is successful + */ + success: boolean; + /** + * The message explaining the error + */ + cause: string; +} +/** + * Error thrown when an error is encountered while querying the hypixel API + * @category Rest + * @group Rest + */ +declare class HypixelAPIError extends Error { + code: number; + constructor(message: string, code: number); +} + +export { HypixelAPIError, type HypixelAPIErrorResponse }; diff --git a/dist/cjs/lib/rest/HypixelAPIError.js b/dist/cjs/lib/rest/HypixelAPIError.js new file mode 100644 index 0000000..8f66118 --- /dev/null +++ b/dist/cjs/lib/rest/HypixelAPIError.js @@ -0,0 +1,42 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/rest/HypixelAPIError.ts +var HypixelAPIError_exports = {}; +__export(HypixelAPIError_exports, { + HypixelAPIError: () => HypixelAPIError +}); +module.exports = __toCommonJS(HypixelAPIError_exports); +var HypixelAPIError = class extends Error { + static { + __name(this, "HypixelAPIError"); + } + code; + constructor(message, code) { + super(message); + this.message = message; + this.code = code; + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + HypixelAPIError +}); +//# sourceMappingURL=HypixelAPIError.js.map \ No newline at end of file diff --git a/dist/cjs/lib/rest/HypixelAPIError.js.map b/dist/cjs/lib/rest/HypixelAPIError.js.map new file mode 100644 index 0000000..7937f84 --- /dev/null +++ b/dist/cjs/lib/rest/HypixelAPIError.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/rest/HypixelAPIError.ts"],"sourcesContent":["/**\r\n * Response body when an error is returned by the hypixel api\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface HypixelAPIErrorResponse {\r\n\t/**\r\n\t * Whether or not the request is successful\r\n\t */\r\n\tsuccess: boolean;\r\n\r\n\t/**\r\n\t * The message explaining the error\r\n\t */\r\n\tcause: string;\r\n}\r\n\r\n/**\r\n * Error thrown when an error is encountered while querying the hypixel API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class HypixelAPIError extends Error {\r\n\tpublic code: number;\r\n\r\n\tpublic constructor(message: string, code: number) {\r\n\t\tsuper(message);\r\n\t\tthis.message = message;\r\n\t\tthis.code = code;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAtB3C,OAsB2C;AAAA;AAAA;AAAA,EACnC;AAAA,EAEA,YAAY,SAAiB,MAAc;AACjD,UAAM,OAAO;AACb,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACb;AACD;","names":[]} \ No newline at end of file diff --git a/dist/cjs/lib/rest/RequestManager.d.ts b/dist/cjs/lib/rest/RequestManager.d.ts new file mode 100644 index 0000000..849eeb5 --- /dev/null +++ b/dist/cjs/lib/rest/RequestManager.d.ts @@ -0,0 +1,2 @@ +export { RequestManager } from '../../index.js'; +import './HypixelAPIError.js'; diff --git a/dist/cjs/lib/rest/RequestManager.js b/dist/cjs/lib/rest/RequestManager.js new file mode 100644 index 0000000..4de767f --- /dev/null +++ b/dist/cjs/lib/rest/RequestManager.js @@ -0,0 +1,181 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/rest/RequestManager.ts +var RequestManager_exports = {}; +__export(RequestManager_exports, { + RequestManager: () => RequestManager2 +}); +module.exports = __toCommonJS(RequestManager_exports); +var import_async_queue = require("@sapphire/async-queue"); + +// src/lib/rest/HypixelAPIError.ts +var HypixelAPIError = class extends Error { + static { + __name(this, "HypixelAPIError"); + } + code; + constructor(message, code) { + super(message); + this.message = message; + this.code = code; + } +}; + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); + +// src/lib/rest/ApiRequest.ts +var ApiRequest = class { + static { + __name(this, "ApiRequest"); + } + /** + * The request manager instance + */ + requests; + /** + * The options of this request + */ + options; + constructor(requestManager, options) { + this.requests = requestManager; + this.options = options; + } + /** + * Makes a request with the options provided. + */ + async make() { + const options = this.buildOptions(); + const res = await fetch(options.url, { + ...options + }); + if (!res.ok) { + const error = await res.json(); + throw new HypixelAPIError(error?.cause ?? res.statusText, res.status); + } + return res; + } + /** + * Creates an object containing the options to be passed to the request + */ + buildOptions() { + const apiKey = this.requests.client.options?.apiKey; + const headers = { + "Content-Type": "application/json" + }; + if (this.options.sendAPIKey) { + if (!apiKey) + throw new HypixelTSError("CLIENT_OPTIONS_MISSING", "apiKey"); + headers["API-Key"] = apiKey; + } + const options = { + url: `${this.requests.baseApiUrl}${this.options.path}`, + method: this.options.method ?? "GET", + headers + }; + return options; + } +}; + +// src/lib/rest/RequestManager.ts +var RequestManager2 = class { + static { + __name(this, "RequestManager"); + } + /** + * The hypixel.ts client instance + */ + client; + /** + * The base url of the hypixel API + */ + baseApiUrl; + /** + * Queue for requests + * @see {@link https://npmjs.com/@sapphire/async-queue} + */ + queue; + constructor(client) { + this.client = client; + this.baseApiUrl = client.options?.baseApiUrl ?? "https://api.hypixel.net"; + this.queue = new import_async_queue.AsyncQueue(); + } + /** + * Makes the api request and pushes it to the request queue + * @param path The path/endpoint to make the request to + * @param sendAPIKey Whether or not to send the apiKey with this request + */ + async execute(path, sendAPIKey) { + await this.queue.wait(); + try { + const request = await new ApiRequest(this, { path, sendAPIKey }).make(); + return request.json(); + } finally { + this.queue.shift(); + } + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + RequestManager +}); +//# sourceMappingURL=RequestManager.js.map \ No newline at end of file diff --git a/dist/cjs/lib/rest/RequestManager.js.map b/dist/cjs/lib/rest/RequestManager.js.map new file mode 100644 index 0000000..12960fe --- /dev/null +++ b/dist/cjs/lib/rest/RequestManager.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/rest/RequestManager.ts","../../../../src/lib/rest/HypixelAPIError.ts","../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/errors/Messages.ts","../../../../src/lib/rest/ApiRequest.ts"],"sourcesContent":["import { AsyncQueue } from '@sapphire/async-queue';\r\nimport { ApiRequest } from './ApiRequest';\r\nimport { Client } from '../Client';\r\n\r\n/**\r\n * Manages the requests to the API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class RequestManager {\r\n\t/**\r\n\t * The hypixel.ts client instance\r\n\t */\r\n\tpublic client: Client;\r\n\r\n\t/**\r\n\t * The base url of the hypixel API\r\n\t */\r\n\tpublic baseApiUrl: string;\r\n\r\n\t/**\r\n\t * Queue for requests\r\n\t * @see {@link https://npmjs.com/@sapphire/async-queue}\r\n\t */\r\n\tprivate queue: AsyncQueue;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t\tthis.baseApiUrl = client.options?.baseApiUrl ?? 'https://api.hypixel.net';\r\n\t\tthis.queue = new AsyncQueue();\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the api request and pushes it to the request queue\r\n\t * @param path The path/endpoint to make the request to\r\n\t * @param sendAPIKey Whether or not to send the apiKey with this request\r\n\t */\r\n\tpublic async execute(path: string, sendAPIKey: boolean) {\r\n\t\tawait this.queue.wait();\r\n\t\ttry {\r\n\t\t\tconst request = await new ApiRequest(this, { path, sendAPIKey }).make();\r\n\t\t\treturn request.json() as T;\r\n\t\t} finally {\r\n\t\t\tthis.queue.shift();\r\n\t\t}\r\n\t}\r\n}\r\n","/**\r\n * Response body when an error is returned by the hypixel api\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface HypixelAPIErrorResponse {\r\n\t/**\r\n\t * Whether or not the request is successful\r\n\t */\r\n\tsuccess: boolean;\r\n\r\n\t/**\r\n\t * The message explaining the error\r\n\t */\r\n\tcause: string;\r\n}\r\n\r\n/**\r\n * Error thrown when an error is encountered while querying the hypixel API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class HypixelAPIError extends Error {\r\n\tpublic code: number;\r\n\r\n\tpublic constructor(message: string, code: number) {\r\n\t\tsuper(message);\r\n\t\tthis.message = message;\r\n\t\tthis.code = code;\r\n\t}\r\n}\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n","import { RequestManager, HypixelAPIError, type HypixelAPIErrorResponse } from './index';\r\nimport { HypixelTSError } from '../errors/index';\r\n\r\n/**\r\n * The options supplied to the request\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface ApiRequestOptions {\r\n\t/**\r\n\t * The request path/endpoint\r\n\t */\r\n\tpath: string;\r\n\r\n\t/**\r\n\t * The request method, only `GET` is supported\r\n\t */\r\n\tmethod?: 'GET';\r\n\r\n\t/**\r\n\t * Whether to send the API key for this request\r\n\t */\r\n\tsendAPIKey?: boolean;\r\n}\r\n\r\n/**\r\n * Handles (sending/building options) requests\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class ApiRequest {\r\n\t/**\r\n\t * The request manager instance\r\n\t */\r\n\tpublic requests: RequestManager;\r\n\r\n\t/**\r\n\t * The options of this request\r\n\t */\r\n\tpublic options: ApiRequestOptions;\r\n\r\n\tpublic constructor(requestManager: RequestManager, options: ApiRequestOptions) {\r\n\t\tthis.requests = requestManager;\r\n\t\tthis.options = options;\r\n\t}\r\n\r\n\t/**\r\n\t * Makes a request with the options provided.\r\n\t */\r\n\tpublic async make() {\r\n\t\tconst options = this.buildOptions();\r\n\r\n\t\tconst res = await fetch(options.url, {\r\n\t\t\t...options\r\n\t\t});\r\n\r\n\t\tif (!res.ok) {\r\n\t\t\tconst error = (await res.json()) as HypixelAPIErrorResponse;\r\n\t\t\tthrow new HypixelAPIError(error?.cause ?? res.statusText, res.status);\r\n\t\t}\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an object containing the options to be passed to the request\r\n\t */\r\n\tpublic buildOptions() {\r\n\t\tconst apiKey = this.requests.client.options?.apiKey;\r\n\r\n\t\tconst headers: Record = {\r\n\t\t\t'Content-Type': 'application/json'\r\n\t\t};\r\n\r\n\t\tif (this.options.sendAPIKey) {\r\n\t\t\tif (!apiKey) throw new HypixelTSError('CLIENT_OPTIONS_MISSING', 'apiKey');\r\n\t\t\theaders['API-Key'] = apiKey;\r\n\t\t}\r\n\r\n\t\tconst options = {\r\n\t\t\turl: `${this.requests.baseApiUrl}${this.options.path}`,\r\n\t\t\tmethod: this.options.method ?? 'GET',\r\n\t\t\theaders\r\n\t\t};\r\n\r\n\t\treturn options;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAAA;AAAA;AAAA;AAAA,yBAA2B;;;ACsBpB,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAtB3C,OAsB2C;AAAA;AAAA;AAAA,EACnC;AAAA,EAEA,YAAY,SAAiB,MAAc;AACjD,UAAM,OAAO;AACb,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AAAA,EAT5B,OAS4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIpB;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC;AAAA,EAED,YAAY,QAAgB;AAClC,SAAK,SAAS;AACd,SAAK,aAAa,OAAO,SAAS,cAAc;AAChD,SAAK,QAAQ,IAAI,8BAAW;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,QAAW,MAAc,YAAqB;AAC1D,UAAM,KAAK,MAAM,KAAK;AACtB,QAAI;AACH,YAAM,UAAU,MAAM,IAAI,WAAW,MAAM,EAAE,MAAM,WAAW,CAAC,EAAE,KAAK;AACtE,aAAO,QAAQ,KAAK;AAAA,IACrB,UAAE;AACD,WAAK,MAAM,MAAM;AAAA,IAClB;AAAA,EACD;AACD;","names":["RequestManager","key","args","messages","RequestManager"]} \ No newline at end of file diff --git a/dist/cjs/lib/rest/index.d.ts b/dist/cjs/lib/rest/index.d.ts new file mode 100644 index 0000000..e8c80a3 --- /dev/null +++ b/dist/cjs/lib/rest/index.d.ts @@ -0,0 +1,2 @@ +export { ApiRequest, ApiRequestOptions, RequestManager } from '../../index.js'; +export { HypixelAPIError, HypixelAPIErrorResponse } from './HypixelAPIError.js'; diff --git a/dist/cjs/lib/rest/index.js b/dist/cjs/lib/rest/index.js new file mode 100644 index 0000000..1aed585 --- /dev/null +++ b/dist/cjs/lib/rest/index.js @@ -0,0 +1,185 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/lib/rest/index.ts +var rest_exports = {}; +__export(rest_exports, { + ApiRequest: () => ApiRequest, + HypixelAPIError: () => HypixelAPIError, + RequestManager: () => RequestManager2 +}); +module.exports = __toCommonJS(rest_exports); + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); + +// src/lib/errors/Messages.ts +var messages2 = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages2)) + register(key, value); + +// src/lib/rest/ApiRequest.ts +var ApiRequest = class { + static { + __name(this, "ApiRequest"); + } + /** + * The request manager instance + */ + requests; + /** + * The options of this request + */ + options; + constructor(requestManager, options) { + this.requests = requestManager; + this.options = options; + } + /** + * Makes a request with the options provided. + */ + async make() { + const options = this.buildOptions(); + const res = await fetch(options.url, { + ...options + }); + if (!res.ok) { + const error = await res.json(); + throw new HypixelAPIError(error?.cause ?? res.statusText, res.status); + } + return res; + } + /** + * Creates an object containing the options to be passed to the request + */ + buildOptions() { + const apiKey = this.requests.client.options?.apiKey; + const headers = { + "Content-Type": "application/json" + }; + if (this.options.sendAPIKey) { + if (!apiKey) + throw new HypixelTSError("CLIENT_OPTIONS_MISSING", "apiKey"); + headers["API-Key"] = apiKey; + } + const options = { + url: `${this.requests.baseApiUrl}${this.options.path}`, + method: this.options.method ?? "GET", + headers + }; + return options; + } +}; + +// src/lib/rest/HypixelAPIError.ts +var HypixelAPIError = class extends Error { + static { + __name(this, "HypixelAPIError"); + } + code; + constructor(message, code) { + super(message); + this.message = message; + this.code = code; + } +}; + +// src/lib/rest/RequestManager.ts +var import_async_queue = require("@sapphire/async-queue"); +var RequestManager2 = class { + static { + __name(this, "RequestManager"); + } + /** + * The hypixel.ts client instance + */ + client; + /** + * The base url of the hypixel API + */ + baseApiUrl; + /** + * Queue for requests + * @see {@link https://npmjs.com/@sapphire/async-queue} + */ + queue; + constructor(client) { + this.client = client; + this.baseApiUrl = client.options?.baseApiUrl ?? "https://api.hypixel.net"; + this.queue = new import_async_queue.AsyncQueue(); + } + /** + * Makes the api request and pushes it to the request queue + * @param path The path/endpoint to make the request to + * @param sendAPIKey Whether or not to send the apiKey with this request + */ + async execute(path, sendAPIKey) { + await this.queue.wait(); + try { + const request = await new ApiRequest(this, { path, sendAPIKey }).make(); + return request.json(); + } finally { + this.queue.shift(); + } + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + ApiRequest, + HypixelAPIError, + RequestManager +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/cjs/lib/rest/index.js.map b/dist/cjs/lib/rest/index.js.map new file mode 100644 index 0000000..41922cb --- /dev/null +++ b/dist/cjs/lib/rest/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/rest/index.ts","../../../../src/lib/errors/HypixelTSError.ts","../../../../src/lib/errors/Messages.ts","../../../../src/lib/rest/ApiRequest.ts","../../../../src/lib/rest/HypixelAPIError.ts","../../../../src/lib/rest/RequestManager.ts"],"sourcesContent":["export * from './ApiRequest';\r\nexport * from './HypixelAPIError';\r\nexport * from './RequestManager';\r\n","type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n","import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n","import { RequestManager, HypixelAPIError, type HypixelAPIErrorResponse } from './index';\r\nimport { HypixelTSError } from '../errors/index';\r\n\r\n/**\r\n * The options supplied to the request\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface ApiRequestOptions {\r\n\t/**\r\n\t * The request path/endpoint\r\n\t */\r\n\tpath: string;\r\n\r\n\t/**\r\n\t * The request method, only `GET` is supported\r\n\t */\r\n\tmethod?: 'GET';\r\n\r\n\t/**\r\n\t * Whether to send the API key for this request\r\n\t */\r\n\tsendAPIKey?: boolean;\r\n}\r\n\r\n/**\r\n * Handles (sending/building options) requests\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class ApiRequest {\r\n\t/**\r\n\t * The request manager instance\r\n\t */\r\n\tpublic requests: RequestManager;\r\n\r\n\t/**\r\n\t * The options of this request\r\n\t */\r\n\tpublic options: ApiRequestOptions;\r\n\r\n\tpublic constructor(requestManager: RequestManager, options: ApiRequestOptions) {\r\n\t\tthis.requests = requestManager;\r\n\t\tthis.options = options;\r\n\t}\r\n\r\n\t/**\r\n\t * Makes a request with the options provided.\r\n\t */\r\n\tpublic async make() {\r\n\t\tconst options = this.buildOptions();\r\n\r\n\t\tconst res = await fetch(options.url, {\r\n\t\t\t...options\r\n\t\t});\r\n\r\n\t\tif (!res.ok) {\r\n\t\t\tconst error = (await res.json()) as HypixelAPIErrorResponse;\r\n\t\t\tthrow new HypixelAPIError(error?.cause ?? res.statusText, res.status);\r\n\t\t}\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an object containing the options to be passed to the request\r\n\t */\r\n\tpublic buildOptions() {\r\n\t\tconst apiKey = this.requests.client.options?.apiKey;\r\n\r\n\t\tconst headers: Record = {\r\n\t\t\t'Content-Type': 'application/json'\r\n\t\t};\r\n\r\n\t\tif (this.options.sendAPIKey) {\r\n\t\t\tif (!apiKey) throw new HypixelTSError('CLIENT_OPTIONS_MISSING', 'apiKey');\r\n\t\t\theaders['API-Key'] = apiKey;\r\n\t\t}\r\n\r\n\t\tconst options = {\r\n\t\t\turl: `${this.requests.baseApiUrl}${this.options.path}`,\r\n\t\t\tmethod: this.options.method ?? 'GET',\r\n\t\t\theaders\r\n\t\t};\r\n\r\n\t\treturn options;\r\n\t}\r\n}\r\n","/**\r\n * Response body when an error is returned by the hypixel api\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface HypixelAPIErrorResponse {\r\n\t/**\r\n\t * Whether or not the request is successful\r\n\t */\r\n\tsuccess: boolean;\r\n\r\n\t/**\r\n\t * The message explaining the error\r\n\t */\r\n\tcause: string;\r\n}\r\n\r\n/**\r\n * Error thrown when an error is encountered while querying the hypixel API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class HypixelAPIError extends Error {\r\n\tpublic code: number;\r\n\r\n\tpublic constructor(message: string, code: number) {\r\n\t\tsuper(message);\r\n\t\tthis.message = message;\r\n\t\tthis.code = code;\r\n\t}\r\n}\r\n","import { AsyncQueue } from '@sapphire/async-queue';\r\nimport { ApiRequest } from './ApiRequest';\r\nimport { Client } from '../Client';\r\n\r\n/**\r\n * Manages the requests to the API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class RequestManager {\r\n\t/**\r\n\t * The hypixel.ts client instance\r\n\t */\r\n\tpublic client: Client;\r\n\r\n\t/**\r\n\t * The base url of the hypixel API\r\n\t */\r\n\tpublic baseApiUrl: string;\r\n\r\n\t/**\r\n\t * Queue for requests\r\n\t * @see {@link https://npmjs.com/@sapphire/async-queue}\r\n\t */\r\n\tprivate queue: AsyncQueue;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t\tthis.baseApiUrl = client.options?.baseApiUrl ?? 'https://api.hypixel.net';\r\n\t\tthis.queue = new AsyncQueue();\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the api request and pushes it to the request queue\r\n\t * @param path The path/endpoint to make the request to\r\n\t * @param sendAPIKey Whether or not to send the apiKey with this request\r\n\t */\r\n\tpublic async execute(path: string, sendAPIKey: boolean) {\r\n\t\tawait this.queue.wait();\r\n\t\ttry {\r\n\t\t\tconst request = await new ApiRequest(this, { path, sendAPIKey }).make();\r\n\t\t\treturn request.json() as T;\r\n\t\t} finally {\r\n\t\t\tthis.queue.shift();\r\n\t\t}\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAAA;AAAA;AAAA;;;ACEA,IAAM,WAAW,oBAAI,IAA2C;AAEzD,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAJ1C,OAI0C;AAAA;AAAA;AAAA,EAClC,YAAY,QAAgB,MAAa;AAC/C,UAAM,WAAW,KAAK,IAAI,CAAC;AAE3B,aAAS,WAAWC,MAAaC,OAAa;AAC7C,UAAI,OAAOD,SAAQ;AAAU,cAAM,IAAI,MAAM,6CAA6C;AAC1F,YAAM,MAAM,SAAS,IAAIA,IAAG;AAE5B,UAAI,CAAC;AAAK,cAAM,IAAI,MAAM,oDAAoDA,IAAG,EAAE;AACnF,UAAI,OAAO,QAAQ;AAAY,eAAO,IAAI,GAAGC,KAAI;AACjD,UAAI,CAACA,MAAK;AAAQ,eAAO;A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AAqB;AAC1D,UAAM,KAAK,MAAM,KAAK;AACtB,QAAI;AACH,YAAM,UAAU,MAAM,IAAI,WAAW,MAAM,EAAE,MAAM,WAAW,CAAC,EAAE,KAAK;AACtE,aAAO,QAAQ,KAAK;AAAA,IACrB,UAAE;AACD,WAAK,MAAM,MAAM;AAAA,IAClB;AAAA,EACD;AACD;","names":["RequestManager","key","args","messages","RequestManager"]} \ No newline at end of file diff --git a/dist/esm/index.d.mts b/dist/esm/index.d.mts new file mode 100644 index 0000000..23dcda6 --- /dev/null +++ b/dist/esm/index.d.mts @@ -0,0 +1,1285 @@ +export { HypixelAPIError, HypixelAPIErrorResponse } from './lib/rest/HypixelAPIError.mjs'; + +/** + * The base manager which all other managers extend from + * @category Managers + * @group Managers + */ +declare class BaseManager { + /** + * Whether or not the manager requires API key authorization. + */ + protected requiresAuth: boolean; + /** + * The instantiated hypixel.ts client + */ + protected client: Client; + constructor(client: Client, requiresAuth: boolean); + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + protected makeGetRequest(path: string): Promise; +} + +/** + * The base class which all other classes extend from. + * @category Classes + * @group Classes + */ +declare class Base { + /** + * The instantiated hypixel.ts client. + */ + protected client: Client; + constructor(client: Client); +} + +/** + * The Guild object returned from the API (in JSON) which is converted to @see {@link Guild} class. + * @category Interfaces + */ +interface APIGuild { + _id: string; + id: string; + name: string; + nameLower: string; + coins: number; + coinsEver: number; + created: number; + members: APIGuildMember[]; + ranks: APIGuildRank[]; + achievements: Record; + exp: number; + guildExpByGameType: Record; +} + +/** + * @category Interfaces + */ +interface APIGuildMember { + uuid: string; + rank: string; + joined: number; + questParticipation: number; + expHistory: Record; +} + +/** + * @category Interfaces + */ +interface APIGuildRank { + name: string; + priority: number; + created: number; + default?: boolean; +} + +/** + * The Player object returned from the API (in JSON) which is converted to the @see {@link Player} class. + * @category Interfaces + */ +interface APIPlayer { + /** + * The uuid of the player. + */ + uuid: string; + + /** + * The display name of the player. + */ + displayName: string | null; + + /** + * The rank of the player + */ + rank: 'ADMIN' | 'MODERATOR' | 'HELPER' | 'NORMAL' | null; + + /** + * The package rank of the player + */ + packageRank: 'MVP_PLUS' | 'MVP' | 'VIP_PLUS' | 'VIP' | 'NONE' | null; + + /** + * The monthly package rank of the player + */ + monthlyPackageRank: 'SUPERSTAR' | 'NONE' | null; + + /** + * First login time of player (in milliseconds) + */ + firstLogin: number | null; + + /** + * Last login time of player (in milliseconds) + */ + lastLogin: number | null; + + /** + * Last logout time of player (in milliseconds) + */ + lastLogout: number | null; + + /** + * Undocumented fields (observed in API response) + */ + knownAliases?: string[]; + knownAliasesLower?: string[]; + playername?: string; + achievementsOneTime?: string[]; + stats: Record; + achievementPoints?: number; + achievements?: Record; + karma?: number; + networkExp?: number; + parkourCheckpointBests?: Record; + parkourCompletions?: Record; + channel?: string; + challenges?: Record; + newPackageRank: string; + levelUp_VIP?: number; + achievementRewardsNew?: Record; + quests?: Record; + levelUp_MVP_PLUS?: number; + currentGadget?: string; + questSettings?: Record; + particlePack?: string; + vanityMeta?: Record; + monthlycrates?: Record; + eugene?: Record; + petConsumables?: Record; + tourney?: Record; + rankPlusColor?: string; + housingMeta?: Record; + mostRecentMonthlyPackageRank?: string; + socialMedia?: Record; + achievementSync?: Record; + lastAdsenseGenerateTime?: number; + lastClaimedReward?: number; + rewardHighScore?: number; + rewardScore?: number; + rewardStreak?: number; + totalDailyRewards?: number; + totalRewards?: number; + currentClickEffect?: string; + disabledProjectileTrails?: boolean; + seasonal?: Record; + adsense_tokens?: number; + monthlyRankColor?: string; + currentPet?: string; + petStats?: Record; + petJourneyTimestamp?: number; + giftingMeta?: Record; + achievementTotem?: Record; + mostRecentGameType?: string; +} + +/** + * The Auction object returned from the API (in JSON) which is converted to the @see {@link SkyBlockAuction} class. + * @category Interfaces + */ +interface APISkyBlockAuction { + _id: string; + id: string; + uuid: string; + auctioneer: string; + profile_id: string; + coop: string[]; + start: number; + end: number; + item_name: string; + item_lore: string; + extra: string; + category: string; + tier: string; + starting_bid: number; + bin: boolean; + item_bytes: { type: number; data: string }; + claimed: boolean; + claimed_bidders: unknown[]; + highest_bid_amount: number; + bids: APISkyBlockAuctionBid[]; +} + +/** + * @category Interfaces + */ +interface APISkyBlockAuctionBid { + auction_id: string; + bidder: string; + profile_id: string; + amount: number; + timestamp: number; +} + +/** + * The Profile object returned from the API (in JSON) which is converted to the @see {@link SkyBlockProfile} class. + * @category Interfaces + */ +interface APISkyBlockProfile { + profile_id: string; + community_upgrades: Record; + + /** + * A map of member UUIDs to member profiles objects + */ + members: APISkyBlockProfileMembers; + + /** + * The cute name of the profile, only provided on the profiles endpoint + */ + cute_name: string | null; + + /** + * Whether or not this is the currently selected profile, only provided on the profiles endpoint + */ + selected: boolean | null; + + /** + * Information about the bank account for this profile, only present if the API banking setting is enabled + */ + banking: APISkyBlockAuctionBanking; + + /** + * The SkyBlock game mode of the profile, not present if normal mode + */ + game_mode: 'ironman' | 'island' | 'bingo'; +} + +/** + * @category Interfaces + */ +interface APISkyBlockProfileMembers { + player_id: string; + /** + * If this field exists, the member profile is marked as deleted + */ + deletion_notice: { + timestamp: number; + }; +} + +/** + * @category Interfaces + */ +interface APISkyBlockAuctionBanking { + balance: number; + transactions: APISkyBlockAuctionBankingTransaction[]; +} + +/** + * @category Interfaces + */ +interface APISkyBlockAuctionBankingTransaction { + timestamp: number; + action: 'DEPOSIT' | 'WITHDRAW'; + initiator_name: string; + amount: number; +} + +/** + * The Museum object returned from the API (in JSON) which is converted to the @see {@link SkyBlockMuseum} class. + * @category Interfaces + */ + +interface APISkyBlockMuseum { + [key: string]: APISkyBlockMuseumMember +} + +interface APISkyBlockMuseumMember { + value: number + appraisal: boolean + items: APISkyBlockMuseumItemObject + special: APISkyBlockMuseumItem[] +} + +interface APISkyBlockMuseumItemObject { + [key: string]: APISkyBlockMuseumItem +} + +/** + * @category Interfaces + */ +interface APISkyBlockMuseumItem { + donated_time: number + items: APISkyBlockMuseumItemItem +} + +/** + * @category Interfaces + */ +interface APISkyBlockMuseumItemItem { + type: number + data: string +} + +/** + * Response returned by mojang API for user uuid lookup + * @category Interfaces + * @see {@link Util.getUUID} + */ +interface GetUUIDResponse { + name: string; + id: string; + errorMessage?: string; +} + +/** + * Response returned by mojang API for user name lookup + * @category Interfaces + * @see {@link Util.getUsername} + */ +interface GetUsernameResponse { + name: string; + uuid: string; + errorMessage?: string; +} + +/** + * Active network boosters returned by the hypixel API + * @category Interfaces + */ +interface ActiveNetworkBoostersResponse { + boosters: ActiveNetworkBoostersResponseActiveBooster; + boosterState: { decrementing: boolean }; +} + +/** + * @category Interfaces + */ +interface ActiveNetworkBoostersResponseActiveBooster { + _id: string; + purchaserUuid: string; + amount: number; + originalLength: number; + length: number; + gameType: number; + dateActivated: number; + stacked: string[] | null; +} + +/** + * @category Interfaces + */ +interface ActiveNetworkBoostersResponseQueuedBooster extends Omit { + stacked: boolean | null; +} + +/** + * Player count returned by hypixel API + * @category Interfaces + */ +interface CurrentPlayerCountsResponse { + playerCount: number; + games: Record }>; +} + +/** + * Current leaderboards returned by the hypixel API + * @category Interfaces + */ +interface CurrentLeaderboardsResponse { + leaderboards: Record; +} + +/** + * Punishment statistics returned by the hypixel API. + * @category Interfaces + */ +interface PunishmentStatisticsResponse { + watchdog_lastMinute: number; + staff_rollingDaily: number; + watchdog_total: number; + watchdog_rollingDaily: number; + staff_total: number; +} + +/** + * Recently played games returned by hypixel API + * @category Interfaces + * @see {@link PlayerManager.getRecentlyPlayedGames} + */ +interface GetRecentlyPlayedGamesResponse { + date: number; + gameType: string; + mode: string; + map: string; + ended: number; +} + +/** + * Status of a player returned by hypixel API + * @category Interfaces + * @see {@link PlayerManager.getStatus} + */ +interface GetStatusResponse { + online: boolean; + gameType: string; + mode: string; + map: string; +} + +/** + * All other responses extend this interface as they have the common property 'lastUpdated'. + * @category Interfaces + */ +interface BaseResourceResponse { + lastUpdated: number; +} + +/** + * Information about hypixel games returned by the hypixel API + * @category Interfaces + * @see {@link ResourceManager.fetchGameInformation} + */ +interface GameInformationResponse extends BaseResourceResponse { + games: Record; +} + +/** + * @category Interfaces + */ +interface GameInformationResponseGame { + id: number; + name: string; + databaseName: string; + modeNames: Record; + legacy?: boolean; + retired?: boolean; +} + +/** + * All achievements returned by the hypixel API. + * @category Interfaces + */ +interface AchievementsResponse extends BaseResourceResponse { + achievements: Record; +} + +/** + * @category Interfaces + */ +interface AchievementsResponseAchievement { + one_time: Record; + tiered: Record; + total_points: number; + total_legacy_points: number; +} + +/** + * @category Interfaces + */ +interface AchievementsResponseAchievementOnetime { + points: number; + name: string; + description: string; + gamePercentUnlocked: number; + globalPercentUnlocked: number; +} + +/** + * @category Interfaces + */ +interface AchievementsResponseAchievementTiered { + name: string; + description: string; + tiers: { tier: number; points: number; amount: number }[]; +} + +/** + * All challenges returned by hypixel API + * @category Interfaces + */ +interface ChallengesResponse extends BaseResourceResponse { + challenges: Record; +} + +/** + * @category Interfaces + */ +interface ChallengesResponseChallenge { + id: string; + name: string; + rewards: { type: string; amount: number }[]; +} + +/** + * All quests returned by the hypixel API + * @category Interfaces + */ +interface QuestsResponse extends BaseResourceResponse { + quests: Record; +} + +/** + * @category Interfaces + */ +interface QuestsResponseQuest { + id: string; + name: string; + description: string; + rewards: { type: string; amount: number }[]; + objectives: { id: string; type: string }[]; + requirements: { type: string }[]; +} + +/** + * All guild achievements returned by the hypixel API + * @category Interfaces + */ +interface GuildAchievementsResponse extends BaseResourceResponse { + one_time: AchievementsResponseAchievementOnetime; + tiered: AchievementsResponseAchievementTiered; +} + +/** + * All vanity pets returned by the hypixel API + * @category Interfaces + */ +interface VanityPetsResponse extends BaseResourceResponse { + types: VanityPetsResponseType[]; + rarities: VanityPetsResponseRarity[]; +} + +/** + * @category Interfaces + */ +interface VanityPetsResponseType { + key: string; + name: string; + rarity: VanityPetsRarity; + package: string; +} + +/** + * @category Interfaces + */ +interface VanityPetsResponseRarity { + name: VanityPetsRarity; + color: string; +} + +/** + * @category Enumerations + */ +declare enum VanityPetsRarity { + COMMON, + RARE, + EPIC, + LEGENDARY +} + +/** + * All vanity companions returned by the hypixel API + * @category Interfaces + */ +interface VanityCompanionsResponse extends VanityPetsResponse {} + +/** + * Information regarding collections returned by the hypixel API. + * @category Interfaces + */ +interface FetchCollectionsResponse extends BaseResourceResponse { + version: string; + collections: Record; +} + +/** + * @category Interfaces + */ +interface FetchCollectionsResponseCollection { + name: string; + items: Record; +} + +/** + * Information regarding skills returned by the hypixel API. + * @category Interfaces + */ +interface FetchSkillsResponse extends BaseResourceResponse { + version: string; + collections: Record; + skills: Record; +} + +/** + * @category Interfaces + */ +interface FetchSkillsResponseCollection { + name: string; + description: string; + maxLevel: number; + levels: Array>; +} + +/** + * @category Interfaces + */ +interface FetchSkillsResponseSkill extends FetchCollectionsResponseCollection {} + +/** + * Information regarding items in the SkyBlock game + * @category Interfaces + */ +interface FetchItemsResponse extends BaseResourceResponse { + items: Array>; +} + +/** + * @category Interfaces + */ +interface FetchItemsResponseItem { + id: string; + name: string; + tier: string; + unstackable: boolean; +} + +/** + * Information regarding the current mayor and ongoing election in SkyBlock + * @category Interfaces + */ +interface FetchElectionAndMayorResponse extends BaseResourceResponse { + mayor: FetchElectionAndMayorResponseMayor; + current?: FetchElectionAndMayorResponseCurrent; +} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseMayor { + key: string; + name: string; + perks: FetchElectionAndMayorResponseMayorPerks[]; + election: FetchElectionAndMayorResponseElection; + current?: FetchElectionAndMayorResponseCurrent; +} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseMayorPerks { + name: string; + description: string; +} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseElection { + year: number; + candidates: FetchElectionAndMayorResponseElectionCandidate[]; +} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseCurrent extends FetchElectionAndMayorResponseElection {} + +/** + * @category Interfaces + */ +interface FetchElectionAndMayorResponseElectionCandidate { + key: string; + name: string; + perks: FetchElectionAndMayorResponseMayorPerks[]; + votes: number; +} + +/** + * Information regarding the current bingo event and its goals + * @category Interfaces + */ +interface FetchActiveBingoGoalsResponse extends BaseResourceResponse { + id: number; + goals: FetchActiveBingoGoalsResponseGoal[]; +} + +/** + * @category Interfaces + */ +interface FetchActiveBingoGoalsResponseGoal { + id: string; + name: string; + tiers?: number[]; + progress?: number; + lore?: string; + requiredAmount?: number; +} + +/** + * News returned by hypixel API + * @category Interfaces + */ +interface FetchNewsResponse extends BaseResourceResponse { + items: FetchNewsResponseItem[]; +} + +/** + * @category Interfaces + */ +interface FetchNewsResponseItem { + item: { + material: string; + }; + link: string; + text: string; + title: string; +} + +/** + * Active auctions returned by the hypixel API + * @category Interfaces + */ +interface FetchActiveAuctionsResponse { + lastUpdated: number; + page: number; + totalPages: number; + totalAuctions: number; + auctions: APISkyBlockAuction[]; +} + +/** + * Recently ended auctions returned by the hypixel API + * @category Interfaces + */ +interface RecentlyEndedAuctionsResponse { + lastUpdated: number; + auctions: RecentlyEndedAuctionsResponseAuction[]; +} + +/** + * @category Interfaces + */ +interface RecentlyEndedAuctionsResponseAuction { + auction_id: string; + seller: string; + seller_profile: string; + buyer: string; + timestamp: number; + price: number; + bin: boolean; + item_bytes: string; +} + +/** + * Bazaar items returned by the hypixel API + * @category Interfaces + */ +interface FetchBazaarResponse { + lastUpdated: number; + products: Record; +} + +/** + * @category Interfaces + */ +interface FetchBazaarResponseProduct { + product_id: string; + sell_summary: FetchBazaarResponseProductSellSummary[]; + buy_summary: FetchBazaarResponseProductBuySummary; + quick_status: FetchBazaarResponseProductQuickStatus; +} + +/** + * @category Interfaces + */ +interface FetchBazaarResponseProductSellSummary { + amount: number; + pricePerUnit: number; + orders: number; +} + +/** + * @category Interfaces + */ +interface FetchBazaarResponseProductBuySummary extends FetchBazaarResponseProductSellSummary {} + +/** + * @category Interfaces + */ +interface FetchBazaarResponseProductQuickStatus { + productId: string; + sellPrice: number; + sellVolume: number; + sellMovingWeek: number; + sellOrders: number; + buyPrice: number; + buyVolume: number; + buyMovingWeek: number; + buyOrders: number; +} + +/** + * Bingo data of a player returned by the hypixel API + * @category Interfaces + */ +interface FetchBingoDataResponse { + events: FetchBingoDataResponseEvent[]; +} + +/** + * @category Interfaces + */ +interface FetchBingoDataResponseEvent { + key: number; + points: number; + completed_goals: string[]; +} + +/** + * @category Interfaces + */ +interface FetchFireSalesResponse { + sales: FetchFireSalesResponseFireSale[]; +} + +/** + * @category Interfaces + */ +interface FetchFireSalesResponseFireSale { + /** + * The SkyBlock item ID for this sale + */ + item_id: string; + /** + * The start time in unix milliseconds for the sale + */ + start: number; + /** + * The end time in unix milliseconds for the sale + */ + end: number; + /** + * The amount of items available for this sale + */ + amount: number; + /** + * The price in Gems for this sale + */ + price: number; +} + +/** + * The guild class + * @category Classes + * @group Classes + * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get} + */ +declare class Guild extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client: Client, data: APIGuild); +} + +/** + * Guild related endpoints + * @category Managers + * @group Managers + */ +declare class GuildManager extends BaseManager { + constructor(client: Client); + /** + * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid + * @param identifier The id/name of the guild or the uuid of the player + * @param type The type of identifier you're passing (id/name of guild, player uuid) + */ + fetch(identifier: string, type: 'id' | 'name' | 'player'): Promise; +} + +/** + * Other endpoints + * @category Managers + * @group Managers + * @see {@link https://api.hypixel.net/#tag/Other} + */ +declare class OtherManager extends BaseManager { + constructor(client: Client); + /** + * Fetch all active network boosters + */ + fetchActiveNetworkBoosters(): Promise; + /** + * Fetch current player counts across all games + */ + fetchCurrentPlayerCounts(): Promise; + /** + * Fetch current leaderboards + */ + fetchCurrentLeaderboards(): Promise; + /** + * Fetch punishment statistics + */ + fetchPunishmentStatistics(): Promise; +} + +interface SkyBlockProfile extends APISkyBlockProfile { +} +/** + * The SkyBlockProfile class. + * @category Classes + * @Group Classes + * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get} + */ +declare class SkyBlockProfile extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client: Client, data: APISkyBlockProfile); +} + +interface Player extends APIPlayer { +} +/** + * The player class + * @category Classes + * @group Classes + * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get} + */ +declare class Player extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client: Client, data: APIPlayer); + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + fetchSkyBlockProfiles(): Promise; +} + +interface SkyBlockAuction extends APISkyBlockAuction { +} +/** + * The sky block auction class + * @category Classes + * @group Classes + * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get} + */ +declare class SkyBlockAuction extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client: Client, data: APISkyBlockAuction); +} + +interface SkyBlockMuseum extends APISkyBlockMuseum { +} +/** + * The SkyBlockMuseum class. + * @category Classes + * @Group Classes + */ +declare class SkyBlockMuseum extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client: Client, data: APISkyBlockMuseum); +} + +/** + * Utility functions + * @category Classes + * @group Classes + */ +declare class Util extends Base { + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static getUUID(name: string): Promise; + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static getUsername(uuid: string): Promise; + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid: string): boolean; +} + +/** + * Player related endpoints. + * @category Managers + * @group Managers + */ +declare class PlayerManager extends BaseManager { + constructor(client: Client); + /** + * Fetch a player using their username or uuid + * @param identifier The username/uuid of the player + */ + fetch(identifier: string): Promise; + /** + * Fetch the recently played games of a player + * @param identifier The username/uuid of the player + */ + getRecentlyPlayedGames(identifier: string): Promise; + /** + * Fetch the status of a player + * @param identifier The username/uuid of the player + */ + getStatus(identifier: string): Promise; + /** + * Resolves the username to a uuid for use in requests + * @param identifier The username (or uuid) of the player + */ + private getUUID; +} + +/** + * Resource endpoints. + * + * **Note**: API Key authorization is not required to use this manager. + * + * @category Managers + * @group Managers + */ +declare class ResourceManager extends BaseManager { + constructor(client: Client); + /** + * Fetch information about Hypixel games + */ + fetchGameInformation(): Promise; + /** + * Fetch all achievements + */ + fetchAchievements(): Promise; + /** + * Fetch all challenges + */ + fetchChallenges(): Promise; + /** + * Fetch all quests + */ + fetchQuests(): Promise; + /** + * Fetch all guild achievements + */ + fetchGuildAchievements(): Promise; + /** + * Fetch all vanity pets + */ + fetchVanityPets(): Promise; + /** + * Fetch all vanity companions + */ + fetchVanityCompanions(): Promise; +} + +/** + * Skyblock related endpoints + * @category Managers + * @group Managers + * @see {@link https://api.hypixel.net/#tag/SkyBlock} + */ +declare class SkyBlockManager extends BaseManager { + constructor(client: Client); + /** + * Fetch information regarding collections in the SkyBlock game + */ + fetchCollections(): Promise; + /** + * Fetch information regarding skills in the SkyBlock game + */ + fetchSkills(): Promise; + /** + * Fetch information regarding items in the SkyBlock game + */ + fetchItems(): Promise; + /** + * Fetch information regarding the current mayor and ongoing election in SkyBlock + */ + fetchElectionAndMayor(): Promise; + /** + * Fetch information regarding the current bingo event and its goals + */ + fetchActiveBingoGoals(): Promise; + /** + * Fetch SkyBlock news + */ + fetchNews(): Promise<{ + items: FetchNewsResponseItem[]; + }>; + /** + * Fetch a SkyBlock auction. + * @param identifier The idenitifer you're using to fetch the auction + * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`) + * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`. + */ + fetchAuction(identifier: string, type: 'uuid' | 'player' | 'profile', raw?: boolean): Promise; + /** + * Fetch the currently active auctions (sorted by last updated first and paginated) + * @param page The page number + * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`. + */ + fetchActiveAuctions(page?: number, resolveAuctions?: boolean): Promise<{ + lastUpdated: number; + page: number; + totalPages: number; + totalAuctions: number; + auctions: APISkyBlockAuction[]; + }>; + /** + * Fetch recently ended auctions (auctions which ended in the last 60 seconds). + */ + fetchRecentlyEndedAuctions(): Promise; + /** + * Fetch bazaar items + */ + fetchBazaar(): Promise; + /** + * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + fetchProfile(profileUuid: string): Promise; + /** + * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + fetchMuseum(profileUuid: string): Promise; + /** + * Fetch a SkyBlock profiles of a player + * @param playerUuid The uuid of the player + */ + fetchPlayerSkyBlockProfiles(playerUuid: string): Promise; + /** + * Fetch bingo data of a player + * @param playerUuid The uuid of the player + */ + fetchBingoData(playerUuid: string): Promise; + /** + * Fetch the currently active or upcoming Fire Sales for SkyBlock + */ + fetchFireSales(): Promise; +} + +/** + * The options supplied to the request + * @category Rest + * @group Rest + */ +interface ApiRequestOptions { + /** + * The request path/endpoint + */ + path: string; + /** + * The request method, only `GET` is supported + */ + method?: 'GET'; + /** + * Whether to send the API key for this request + */ + sendAPIKey?: boolean; +} +/** + * Handles (sending/building options) requests + * @category Rest + * @group Rest + */ +declare class ApiRequest { + /** + * The request manager instance + */ + requests: RequestManager; + /** + * The options of this request + */ + options: ApiRequestOptions; + constructor(requestManager: RequestManager, options: ApiRequestOptions); + /** + * Makes a request with the options provided. + */ + make(): Promise; + /** + * Creates an object containing the options to be passed to the request + */ + buildOptions(): { + url: string; + method: "GET"; + headers: Record; + }; +} + +/** + * Manages the requests to the API + * @category Rest + * @group Rest + */ +declare class RequestManager { + /** + * The hypixel.ts client instance + */ + client: Client; + /** + * The base url of the hypixel API + */ + baseApiUrl: string; + /** + * Queue for requests + * @see {@link https://npmjs.com/@sapphire/async-queue} + */ + private queue; + constructor(client: Client); + /** + * Makes the api request and pushes it to the request queue + * @param path The path/endpoint to make the request to + * @param sendAPIKey Whether or not to send the apiKey with this request + */ + execute(path: string, sendAPIKey: boolean): Promise; +} + +/** + * The hypixel.ts client. + * @category Classes + */ +declare class Client { + options?: ClientOptions; + requests: RequestManager; + players: PlayerManager; + guilds: GuildManager; + resources: ResourceManager; + others: OtherManager; + skyblock: SkyBlockManager; + constructor(options?: ClientOptions); + /** + * Starts the hypixel client (registers all managers) + * *NOTE*: This method must be called before further usage. + */ + start(): this; + /** + * Register all the managers + */ + private registerManagers; +} + +/** + * The client options. + * @category Interfaces + */ +interface ClientOptions { + /** + * The hypixel api key. + * This is optional to provide as some managers support non auth requests. + */ + apiKey?: string; + /** + * The base hypixel api url + * @private + */ + baseApiUrl?: string; +} + +export { type APIGuild, type APIGuildMember, type APIGuildRank, type APIPlayer, type APISkyBlockAuction, type APISkyBlockAuctionBanking, type APISkyBlockAuctionBankingTransaction, type APISkyBlockAuctionBid, type APISkyBlockMuseum, type APISkyBlockMuseumItem, type APISkyBlockMuseumItemItem, type APISkyBlockMuseumItemObject, type APISkyBlockMuseumMember, type APISkyBlockProfile, type APISkyBlockProfileMembers, type AchievementsResponse, type AchievementsResponseAchievement, type AchievementsResponseAchievementOnetime, type AchievementsResponseAchievementTiered, type ActiveNetworkBoostersResponse, type ActiveNetworkBoostersResponseActiveBooster, type ActiveNetworkBoostersResponseQueuedBooster, ApiRequest, type ApiRequestOptions, Base, BaseManager, type BaseResourceResponse, type ChallengesResponse, type ChallengesResponseChallenge, Client, type ClientOptions, type CurrentLeaderboardsResponse, type CurrentPlayerCountsResponse, type FetchActiveAuctionsResponse, type FetchActiveBingoGoalsResponse, type FetchActiveBingoGoalsResponseGoal, type FetchBazaarResponse, type FetchBazaarResponseProduct, type FetchBazaarResponseProductBuySummary, type FetchBazaarResponseProductQuickStatus, type FetchBazaarResponseProductSellSummary, type FetchBingoDataResponse, type FetchBingoDataResponseEvent, type FetchCollectionsResponse, type FetchCollectionsResponseCollection, type FetchElectionAndMayorResponse, type FetchElectionAndMayorResponseCurrent, type FetchElectionAndMayorResponseElection, type FetchElectionAndMayorResponseElectionCandidate, type FetchElectionAndMayorResponseMayor, type FetchElectionAndMayorResponseMayorPerks, type FetchFireSalesResponse, type FetchFireSalesResponseFireSale, type FetchItemsResponse, type FetchItemsResponseItem, type FetchNewsResponse, type FetchNewsResponseItem, type FetchSkillsResponse, type FetchSkillsResponseCollection, type FetchSkillsResponseSkill, type GameInformationResponse, type GameInformationResponseGame, type GetRecentlyPlayedGamesResponse, type GetStatusResponse, type GetUUIDResponse, type GetUsernameResponse, Guild, type GuildAchievementsResponse, GuildManager, OtherManager, Player, PlayerManager, type PunishmentStatisticsResponse, type QuestsResponse, type QuestsResponseQuest, type RecentlyEndedAuctionsResponse, type RecentlyEndedAuctionsResponseAuction, RequestManager, ResourceManager, SkyBlockAuction, SkyBlockManager, SkyBlockMuseum, SkyBlockProfile, Util, type VanityCompanionsResponse, VanityPetsRarity, type VanityPetsResponse, type VanityPetsResponseRarity, type VanityPetsResponseType }; diff --git a/dist/esm/index.mjs b/dist/esm/index.mjs new file mode 100644 index 0000000..6cba4ef --- /dev/null +++ b/dist/esm/index.mjs @@ -0,0 +1,3 @@ +// src/index.ts +export * from "./lib/index.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/dist/esm/index.mjs.map b/dist/esm/index.mjs.map new file mode 100644 index 0000000..94852b8 --- /dev/null +++ b/dist/esm/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './lib/index';\r\n\r\n/**\r\n * The client options.\r\n * @category Interfaces\r\n */\r\nexport interface ClientOptions {\r\n\t/**\r\n\t * The hypixel api key.\r\n\t * This is optional to provide as some managers support non auth requests.\r\n\t */\r\n\tapiKey?: string;\r\n\r\n\t/**\r\n\t * The base hypixel api url\r\n\t * @private\r\n\t */\r\n\tbaseApiUrl?: string;\r\n}\r\n"],"mappings":";AAAA,cAAc;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/Client.d.mts b/dist/esm/lib/Client.d.mts new file mode 100644 index 0000000..27b595f --- /dev/null +++ b/dist/esm/lib/Client.d.mts @@ -0,0 +1,2 @@ +export { Client } from '../index.mjs'; +import './rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/Client.mjs b/dist/esm/lib/Client.mjs new file mode 100644 index 0000000..1df788b --- /dev/null +++ b/dist/esm/lib/Client.mjs @@ -0,0 +1,45 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/Client.ts +import { PlayerManager, GuildManager, ResourceManager, OtherManager, SkyBlockManager } from "./managers/index.mjs"; +import { RequestManager } from "./rest/index.mjs"; +var Client = class { + static { + __name(this, "Client"); + } + options; + requests; + players; + guilds; + resources; + others; + skyblock; + constructor(options) { + this.options = options ?? {}; + this.options.baseApiUrl = "https://api.hypixel.net"; + } + /** + * Starts the hypixel client (registers all managers) + * *NOTE*: This method must be called before further usage. + */ + start() { + this.registerManagers(); + return this; + } + /** + * Register all the managers + */ + registerManagers() { + this.requests = new RequestManager(this); + this.players = new PlayerManager(this); + this.guilds = new GuildManager(this); + this.resources = new ResourceManager(this); + this.others = new OtherManager(this); + this.skyblock = new SkyBlockManager(this); + } +}; +export { + Client +}; +//# sourceMappingURL=Client.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/Client.mjs.map b/dist/esm/lib/Client.mjs.map new file mode 100644 index 0000000..dc4402e --- /dev/null +++ b/dist/esm/lib/Client.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/lib/Client.ts"],"sourcesContent":["import { PlayerManager, GuildManager, ResourceManager, OtherManager, SkyBlockManager } from './managers/index';\r\nimport { RequestManager } from './rest/index';\r\nimport type { ClientOptions } from '../index';\r\n\r\n/**\r\n * The hypixel.ts client.\r\n * @category Classes\r\n */\r\nexport class Client {\r\n\tpublic options?: ClientOptions;\r\n\tpublic requests!: RequestManager;\r\n\tpublic players!: PlayerManager;\r\n\tpublic guilds!: GuildManager;\r\n\tpublic resources!: ResourceManager;\r\n\tpublic others!: OtherManager;\r\n\tpublic skyblock!: SkyBlockManager;\r\n\r\n\tpublic constructor(options?: ClientOptions) {\r\n\t\tthis.options = options ?? {};\r\n\t\tthis.options.baseApiUrl = 'https://api.hypixel.net';\r\n\t}\r\n\r\n\t/**\r\n\t * Starts the hypixel client (registers all managers)\r\n\t * *NOTE*: This method must be called before further usage.\r\n\t */\r\n\tpublic start() {\r\n\t\tthis.registerManagers();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Register all the managers\r\n\t */\r\n\tprivate registerManagers() {\r\n\t\tthis.requests = new RequestManager(this);\r\n\t\tthis.players = new PlayerManager(this);\r\n\t\tthis.guilds = new GuildManager(this);\r\n\t\tthis.resources = new ResourceManager(this);\r\n\t\tthis.others = new OtherManager(this);\r\n\t\tthis.skyblock = new SkyBlockManager(this);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,eAAe,cAAc,iBAAiB,cAAc,uBAAuB;AAC5F,SAAS,sBAAsB;AAOxB,IAAM,SAAN,MAAa;AAAA,EARpB,OAQoB;AAAA;AAAA;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,SAAyB;AAC3C,SAAK,UAAU,WAAW,CAAC;AAC3B,SAAK,QAAQ,aAAa;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,QAAQ;AACd,SAAK,iBAAiB;AACtB,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB;AAC1B,SAAK,WAAW,IAAI,eAAe,IAAI;AACvC,SAAK,UAAU,IAAI,cAAc,IAAI;AACrC,SAAK,SAAS,IAAI,aAAa,IAAI;AACnC,SAAK,YAAY,IAAI,gBAAgB,IAAI;AACzC,SAAK,SAAS,IAAI,aAAa,IAAI;AACnC,SAAK,WAAW,IAAI,gBAAgB,IAAI;AAAA,EACzC;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/classes/Base.d.mts b/dist/esm/lib/classes/Base.d.mts new file mode 100644 index 0000000..31682b6 --- /dev/null +++ b/dist/esm/lib/classes/Base.d.mts @@ -0,0 +1,2 @@ +export { Base } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/classes/Base.mjs b/dist/esm/lib/classes/Base.mjs new file mode 100644 index 0000000..f7f3031 --- /dev/null +++ b/dist/esm/lib/classes/Base.mjs @@ -0,0 +1,20 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/classes/Base.ts +var Base = class { + static { + __name(this, "Base"); + } + /** + * The instantiated hypixel.ts client. + */ + client; + constructor(client) { + this.client = client; + } +}; +export { + Base +}; +//# sourceMappingURL=Base.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/classes/Base.mjs.map b/dist/esm/lib/classes/Base.mjs.map new file mode 100644 index 0000000..edaa3fc --- /dev/null +++ b/dist/esm/lib/classes/Base.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/Base.ts"],"sourcesContent":["import type { Client } from '../Client';\r\n\r\n/**\r\n * The base class which all other classes extend from.\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Base {\r\n\t/**\r\n\t * The instantiated hypixel.ts client.\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t}\r\n}\r\n"],"mappings":";;;;AAOO,IAAM,OAAN,MAAW;AAAA,EAPlB,OAOkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA,EAEH,YAAY,QAAgB;AAClC,SAAK,SAAS;AAAA,EACf;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/classes/Guild.d.mts b/dist/esm/lib/classes/Guild.d.mts new file mode 100644 index 0000000..c09b973 --- /dev/null +++ b/dist/esm/lib/classes/Guild.d.mts @@ -0,0 +1,2 @@ +export { Guild } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/classes/Guild.mjs b/dist/esm/lib/classes/Guild.mjs new file mode 100644 index 0000000..5d8c508 --- /dev/null +++ b/dist/esm/lib/classes/Guild.mjs @@ -0,0 +1,23 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/classes/Guild.ts +import { Base } from "./Base.mjs"; +var Guild = class extends Base { + static { + __name(this, "Guild"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Guild data received from API + */ + constructor(client, data) { + super(client); + data.id = data._id; + Object.assign(this, data); + } +}; +export { + Guild +}; +//# sourceMappingURL=Guild.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/classes/Guild.mjs.map b/dist/esm/lib/classes/Guild.mjs.map new file mode 100644 index 0000000..bc40b78 --- /dev/null +++ b/dist/esm/lib/classes/Guild.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/Guild.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APIGuild } from '../typings';\r\n\r\n/**\r\n * The guild class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1guild/get}\r\n */\r\nexport class Guild extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Guild data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIGuild) {\r\n\t\tsuper(client);\r\n\t\tdata.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,YAAY;AAUd,IAAM,QAAN,cAAoB,KAAK;AAAA,EAVhC,OAUgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,YAAY,QAAgB,MAAgB;AAClD,UAAM,MAAM;AACZ,SAAK,KAAK,KAAK;AACf,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/classes/Player.d.mts b/dist/esm/lib/classes/Player.d.mts new file mode 100644 index 0000000..4f48504 --- /dev/null +++ b/dist/esm/lib/classes/Player.d.mts @@ -0,0 +1,2 @@ +export { Player } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/classes/Player.mjs b/dist/esm/lib/classes/Player.mjs new file mode 100644 index 0000000..f204b7f --- /dev/null +++ b/dist/esm/lib/classes/Player.mjs @@ -0,0 +1,29 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/classes/Player.ts +import { Base } from "./Base.mjs"; +var Player = class extends Base { + static { + __name(this, "Player"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data Player data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } + /** + * Fetch the SkyBlock profiles of this player + * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles} + */ + async fetchSkyBlockProfiles() { + return this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid); + } +}; +export { + Player +}; +//# sourceMappingURL=Player.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/classes/Player.mjs.map b/dist/esm/lib/classes/Player.mjs.map new file mode 100644 index 0000000..3ed54c4 --- /dev/null +++ b/dist/esm/lib/classes/Player.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/Player.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport { Client } from '../Client';\r\nimport { APIPlayer } from '../typings';\r\n\r\nexport interface Player extends APIPlayer {}\r\n/**\r\n * The player class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/Player-Data/paths/~1player/get}\r\n */\r\nexport class Player extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data Player data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APIPlayer) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the SkyBlock profiles of this player\r\n\t * @see {@link SkyBlockManager.fetchPlayerSkyBlockProfiles}\r\n\t */\r\n\tpublic async fetchSkyBlockProfiles() {\r\n\t\treturn this.client.skyblock.fetchPlayerSkyBlockProfiles(this.uuid);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,YAAY;AAWd,IAAM,SAAN,cAAqB,KAAK;AAAA,EAXjC,OAWiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,YAAY,QAAgB,MAAiB;AACnD,UAAM,MAAM;AACZ,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,wBAAwB;AACpC,WAAO,KAAK,OAAO,SAAS,4BAA4B,KAAK,IAAI;AAAA,EAClE;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/classes/SkyBlockAuction.d.mts b/dist/esm/lib/classes/SkyBlockAuction.d.mts new file mode 100644 index 0000000..cd57e51 --- /dev/null +++ b/dist/esm/lib/classes/SkyBlockAuction.d.mts @@ -0,0 +1,2 @@ +export { SkyBlockAuction } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/classes/SkyBlockAuction.mjs b/dist/esm/lib/classes/SkyBlockAuction.mjs new file mode 100644 index 0000000..81f0a89 --- /dev/null +++ b/dist/esm/lib/classes/SkyBlockAuction.mjs @@ -0,0 +1,24 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/classes/SkyBlockAuction.ts +import { Base } from "./Base.mjs"; +var SkyBlockAuction = class extends Base { + static { + __name(this, "SkyBlockAuction"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock auction data received from API + */ + constructor(client, data) { + super(client); + if ("_id" in data) + data.id = data._id; + Object.assign(this, data); + } +}; +export { + SkyBlockAuction +}; +//# sourceMappingURL=SkyBlockAuction.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/classes/SkyBlockAuction.mjs.map b/dist/esm/lib/classes/SkyBlockAuction.mjs.map new file mode 100644 index 0000000..c4205a3 --- /dev/null +++ b/dist/esm/lib/classes/SkyBlockAuction.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/SkyBlockAuction.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockAuction } from '../typings';\r\n\r\nexport interface SkyBlockAuction extends APISkyBlockAuction {}\r\n/**\r\n * The sky block auction class\r\n * @category Classes\r\n * @group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1auction/get}\r\n */\r\nexport class SkyBlockAuction extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock auction data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockAuction) {\r\n\t\tsuper(client);\r\n\t\tif ('_id' in data) data.id = data._id;\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,YAAY;AAWd,IAAM,kBAAN,cAA8B,KAAK;AAAA,EAX1C,OAW0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,YAAY,QAAgB,MAA0B;AAC5D,UAAM,MAAM;AACZ,QAAI,SAAS;AAAM,WAAK,KAAK,KAAK;AAClC,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/classes/SkyBlockMuseum.d.mts b/dist/esm/lib/classes/SkyBlockMuseum.d.mts new file mode 100644 index 0000000..2e002d4 --- /dev/null +++ b/dist/esm/lib/classes/SkyBlockMuseum.d.mts @@ -0,0 +1,2 @@ +export { SkyBlockMuseum } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/classes/SkyBlockMuseum.mjs b/dist/esm/lib/classes/SkyBlockMuseum.mjs new file mode 100644 index 0000000..07c2020 --- /dev/null +++ b/dist/esm/lib/classes/SkyBlockMuseum.mjs @@ -0,0 +1,22 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/classes/SkyBlockMuseum.ts +import { Base } from "./Base.mjs"; +var SkyBlockMuseum = class extends Base { + static { + __name(this, "SkyBlockMuseum"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; +export { + SkyBlockMuseum +}; +//# sourceMappingURL=SkyBlockMuseum.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/classes/SkyBlockMuseum.mjs.map b/dist/esm/lib/classes/SkyBlockMuseum.mjs.map new file mode 100644 index 0000000..6f06e74 --- /dev/null +++ b/dist/esm/lib/classes/SkyBlockMuseum.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/SkyBlockMuseum.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockMuseum } from '../typings';\r\n\r\nexport interface SkyBlockMuseum extends APISkyBlockMuseum {}\r\n/**\r\n * The SkyBlockMuseum class.\r\n * @category Classes\r\n * @Group Classes\r\n */\r\nexport class SkyBlockMuseum extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockMuseum) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,YAAY;AAUd,IAAM,iBAAN,cAA6B,KAAK;AAAA,EAVzC,OAUyC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjC,YAAY,QAAgB,MAAyB;AAC3D,UAAM,MAAM;AACZ,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/classes/SkyBlockProfile.d.mts b/dist/esm/lib/classes/SkyBlockProfile.d.mts new file mode 100644 index 0000000..ec20321 --- /dev/null +++ b/dist/esm/lib/classes/SkyBlockProfile.d.mts @@ -0,0 +1,2 @@ +export { SkyBlockProfile } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/classes/SkyBlockProfile.mjs b/dist/esm/lib/classes/SkyBlockProfile.mjs new file mode 100644 index 0000000..aca6788 --- /dev/null +++ b/dist/esm/lib/classes/SkyBlockProfile.mjs @@ -0,0 +1,22 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/classes/SkyBlockProfile.ts +import { Base } from "./Base.mjs"; +var SkyBlockProfile = class extends Base { + static { + __name(this, "SkyBlockProfile"); + } + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + constructor(client, data) { + super(client); + Object.assign(this, data); + } +}; +export { + SkyBlockProfile +}; +//# sourceMappingURL=SkyBlockProfile.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/classes/SkyBlockProfile.mjs.map b/dist/esm/lib/classes/SkyBlockProfile.mjs.map new file mode 100644 index 0000000..45e87dd --- /dev/null +++ b/dist/esm/lib/classes/SkyBlockProfile.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/SkyBlockProfile.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport type { Client } from '../Client';\r\nimport type { APISkyBlockProfile } from '../typings';\r\n\r\nexport interface SkyBlockProfile extends APISkyBlockProfile {}\r\n/**\r\n * The SkyBlockProfile class.\r\n * @category Classes\r\n * @Group Classes\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock/paths/~1skyblock~1profile/get}\r\n */\r\nexport class SkyBlockProfile extends Base {\r\n\t/**\r\n\t * @param client Instantiated (and started) hypixel.ts client\r\n\t * @param data SkyBlock profile data received from API\r\n\t */\r\n\tpublic constructor(client: Client, data: APISkyBlockProfile) {\r\n\t\tsuper(client);\r\n\t\tObject.assign(this, data);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,YAAY;AAWd,IAAM,kBAAN,cAA8B,KAAK;AAAA,EAX1C,OAW0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,YAAY,QAAgB,MAA0B;AAC5D,UAAM,MAAM;AACZ,WAAO,OAAO,MAAM,IAAI;AAAA,EACzB;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/classes/Util.d.mts b/dist/esm/lib/classes/Util.d.mts new file mode 100644 index 0000000..877aedc --- /dev/null +++ b/dist/esm/lib/classes/Util.d.mts @@ -0,0 +1,2 @@ +export { Util } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/classes/Util.mjs b/dist/esm/lib/classes/Util.mjs new file mode 100644 index 0000000..167bc67 --- /dev/null +++ b/dist/esm/lib/classes/Util.mjs @@ -0,0 +1,57 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/classes/Util.ts +import { Base } from "./Base.mjs"; +import { HypixelTSError } from "../errors/HypixelTSError.mjs"; +var Util = class extends Base { + static { + __name(this, "Util"); + } + /** + * Get the UUID of a player by providing their name + * @param name The name of the player + */ + static async getUUID(name) { + try { + const data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_UUID_ERROR", json.errorMessage, data.status); + return json.id; + } catch { + throw new HypixelTSError("GET_UUID_404"); + } + } + /** + * Get player's name from their UUID + * @param uuid The uuid of the player + */ + static async getUsername(uuid) { + if (!this.isUUID(uuid)) { + throw new HypixelTSError("NOT_UUID"); + } + try { + const data = await fetch(`https://api.mojang.com/user/profile/${uuid}`); + const json = await data.json(); + if (json.errorMessage) + throw new HypixelTSError("GET_USERNAME_ERROR", json.errorMessage, data.status); + return json.name; + } catch { + throw new HypixelTSError("GET_USERNAME_404"); + } + } + /** + * Check whether the provided UUID is a valid UUID or not + * @param uuid The UUID to check + */ + static isUUID(uuid) { + const regexStripped = /^[0-9a-f]{32}$/i; + const regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}$/i; + return regexStripped.test(uuid) || regexFull.test(uuid); + } +}; +export { + Util +}; +//# sourceMappingURL=Util.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/classes/Util.mjs.map b/dist/esm/lib/classes/Util.mjs.map new file mode 100644 index 0000000..5a385f7 --- /dev/null +++ b/dist/esm/lib/classes/Util.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/Util.ts"],"sourcesContent":["import { Base } from './Base';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport type { GetUsernameResponse, GetUUIDResponse } from '../typings';\r\n\r\n/**\r\n * Utility functions\r\n * @category Classes\r\n * @group Classes\r\n */\r\nexport class Util extends Base {\r\n\t/**\r\n\t * Get the UUID of a player by providing their name\r\n\t * @param name The name of the player\r\n\t */\r\n\tpublic static async getUUID(name: string): Promise {\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/users/profiles/minecraft/${name}`);\r\n\t\t\tconst json = (await data.json()) as GetUUIDResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_UUID_ERROR', json.errorMessage, data.status);\r\n\t\t\treturn json.id;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_UUID_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Get player's name from their UUID\r\n\t * @param uuid The uuid of the player\r\n\t */\r\n\tpublic static async getUsername(uuid: string): Promise {\r\n\t\tif (!this.isUUID(uuid)) {\r\n\t\t\tthrow new HypixelTSError('NOT_UUID');\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst data = await fetch(`https://api.mojang.com/user/profile/${uuid}`);\r\n\t\t\tconst json = (await data.json()) as GetUsernameResponse;\r\n\r\n\t\t\tif (json.errorMessage) throw new HypixelTSError('GET_USERNAME_ERROR', json.errorMessage, data.status);\r\n\r\n\t\t\treturn json.name;\r\n\t\t} catch {\r\n\t\t\tthrow new HypixelTSError('GET_USERNAME_404');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Check whether the provided UUID is a valid UUID or not\r\n\t * @param uuid The UUID to check\r\n\t */\r\n\tpublic static isUUID(uuid: string) {\r\n\t\tconst regexStripped = /^[0-9a-f]{32}$/i;\r\n\t\tconst regexFull = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}$/i;\r\n\t\treturn regexStripped.test(uuid) || regexFull.test(uuid);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,YAAY;AACrB,SAAS,sBAAsB;AAQxB,IAAM,OAAN,cAAmB,KAAK;AAAA,EAT/B,OAS+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9B,aAAoB,QAAQ,MAA+B;AAC1D,QAAI;AACH,YAAM,OAAO,MAAM,MAAM,mDAAmD,IAAI,EAAE;AAClF,YAAM,OAAQ,MAAM,KAAK,KAAK;AAE9B,UAAI,KAAK;AAAc,cAAM,IAAI,eAAe,kBAAkB,KAAK,cAAc,KAAK,MAAM;AAChG,aAAO,KAAK;AAAA,IACb,QAAQ;AACP,YAAM,IAAI,eAAe,cAAc;AAAA,IACxC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAoB,YAAY,MAA+B;AAC9D,QAAI,CAAC,KAAK,OAAO,IAAI,GAAG;AACvB,YAAM,IAAI,eAAe,UAAU;AAAA,IACpC;AAEA,QAAI;AACH,YAAM,OAAO,MAAM,MAAM,uCAAuC,IAAI,EAAE;AACtE,YAAM,OAAQ,MAAM,KAAK,KAAK;AAE9B,UAAI,KAAK;AAAc,cAAM,IAAI,eAAe,sBAAsB,KAAK,cAAc,KAAK,MAAM;AAEpG,aAAO,KAAK;AAAA,IACb,QAAQ;AACP,YAAM,IAAI,eAAe,kBAAkB;AAAA,IAC5C;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,OAAO,MAAc;AAClC,UAAM,gBAAgB;AACtB,UAAM,YAAY;AAClB,WAAO,cAAc,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI;AAAA,EACvD;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/classes/index.d.mts b/dist/esm/lib/classes/index.d.mts new file mode 100644 index 0000000..0455cff --- /dev/null +++ b/dist/esm/lib/classes/index.d.mts @@ -0,0 +1,2 @@ +export { Base, Guild, Player, SkyBlockAuction, SkyBlockMuseum, SkyBlockProfile, Util } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/classes/index.mjs b/dist/esm/lib/classes/index.mjs new file mode 100644 index 0000000..1ae44f6 --- /dev/null +++ b/dist/esm/lib/classes/index.mjs @@ -0,0 +1,9 @@ +// src/lib/classes/index.ts +export * from "./Base.mjs"; +export * from "./Guild.mjs"; +export * from "./Player.mjs"; +export * from "./SkyBlockAuction.mjs"; +export * from "./SkyBlockProfile.mjs"; +export * from "./SkyBlockMuseum.mjs"; +export * from "./Util.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/classes/index.mjs.map b/dist/esm/lib/classes/index.mjs.map new file mode 100644 index 0000000..cc819bc --- /dev/null +++ b/dist/esm/lib/classes/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/classes/index.ts"],"sourcesContent":["export * from './Base';\r\n\r\nexport * from './Guild';\r\nexport * from './Player';\r\nexport * from './SkyBlockAuction';\r\nexport * from './SkyBlockProfile';\r\nexport * from './SkyBlockMuseum';\r\nexport * from './Util';\r\n"],"mappings":";AAAA,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/errors/HypixelTSError.d.mts b/dist/esm/lib/errors/HypixelTSError.d.mts new file mode 100644 index 0000000..ad51c18 --- /dev/null +++ b/dist/esm/lib/errors/HypixelTSError.d.mts @@ -0,0 +1,6 @@ +declare class HypixelTSError extends Error { + constructor(key: string, ...args: any[]); +} +declare function register(name: string, value: any): void; + +export { HypixelTSError, register }; diff --git a/dist/esm/lib/errors/HypixelTSError.mjs b/dist/esm/lib/errors/HypixelTSError.mjs new file mode 100644 index 0000000..48cd645 --- /dev/null +++ b/dist/esm/lib/errors/HypixelTSError.mjs @@ -0,0 +1,36 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/errors/HypixelTSError.ts +var messages = /* @__PURE__ */ new Map(); +var HypixelTSError = class extends Error { + static { + __name(this, "HypixelTSError"); + } + constructor(key, ...args) { + super(getMessage(key, args)); + function getMessage(key2, args2) { + if (typeof key2 !== "string") + throw new Error("[getMessage]: argument key must be a string"); + const msg = messages.get(key2); + if (!msg) + throw new Error(`[getMessage]: An invalid error key was provided: ${key2}`); + if (typeof msg === "function") + return msg(...args2); + if (!args2.length) + return msg; + args2.unshift(msg); + return String(...args2); + } + __name(getMessage, "getMessage"); + } +}; +function register(name, value) { + messages.set(name, typeof value === "function" ? value : String(value)); +} +__name(register, "register"); +export { + HypixelTSError, + register +}; +//# sourceMappingURL=HypixelTSError.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/errors/HypixelTSError.mjs.map b/dist/esm/lib/errors/HypixelTSError.mjs.map new file mode 100644 index 0000000..fd9f481 --- /dev/null +++ b/dist/esm/lib/errors/HypixelTSError.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/errors/HypixelTSError.ts"],"sourcesContent":["type ErrorMessageSupplier = (...args: any[]) => string;\r\n\r\nconst messages = new Map();\r\n\r\nexport class HypixelTSError extends Error {\r\n\tpublic constructor(key: string, ...args: any[]) {\r\n\t\tsuper(getMessage(key, args));\r\n\r\n\t\tfunction getMessage(key: string, args: any[]) {\r\n\t\t\tif (typeof key !== 'string') throw new Error('[getMessage]: argument key must be a string');\r\n\t\t\tconst msg = messages.get(key);\r\n\r\n\t\t\tif (!msg) throw new Error(`[getMessage]: An invalid error key was provided: ${key}`);\r\n\t\t\tif (typeof msg === 'function') return msg(...args);\r\n\t\t\tif (!args.length) return msg;\r\n\r\n\t\t\targs.unshift(msg);\r\n\t\t\treturn String(...args);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function register(name: string, value: any) {\r\n\tmessages.set(name, typeof value === 'function' ? value : String(value));\r\n}\r\n"],"mappings":";;;;AAEA,IAAM,WAAW,oBAAI,IAA2C;AAEzD,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAJ1C,OAI0C;AAAA;AAAA;AAAA,EAClC,YAAY,QAAgB,MAAa;AAC/C,UAAM,WAAW,KAAK,IAAI,CAAC;AAE3B,aAAS,WAAWA,MAAaC,OAAa;AAC7C,UAAI,OAAOD,SAAQ;AAAU,cAAM,IAAI,MAAM,6CAA6C;AAC1F,YAAM,MAAM,SAAS,IAAIA,IAAG;AAE5B,UAAI,CAAC;AAAK,cAAM,IAAI,MAAM,oDAAoDA,IAAG,EAAE;AACnF,UAAI,OAAO,QAAQ;AAAY,eAAO,IAAI,GAAGC,KAAI;AACjD,UAAI,CAACA,MAAK;AAAQ,eAAO;AAEzB,MAAAA,MAAK,QAAQ,GAAG;AAChB,aAAO,OAAO,GAAGA,KAAI;AAAA,IACtB;AAVS;AAAA,EAWV;AACD;AAEO,SAAS,SAAS,MAAc,OAAY;AAClD,WAAS,IAAI,MAAM,OAAO,UAAU,aAAa,QAAQ,OAAO,KAAK,CAAC;AACvE;AAFgB;","names":["key","args"]} \ No newline at end of file diff --git a/dist/esm/lib/errors/Messages.d.mts b/dist/esm/lib/errors/Messages.d.mts new file mode 100644 index 0000000..223e65e --- /dev/null +++ b/dist/esm/lib/errors/Messages.d.mts @@ -0,0 +1,2 @@ + +export { } diff --git a/dist/esm/lib/errors/Messages.mjs b/dist/esm/lib/errors/Messages.mjs new file mode 100644 index 0000000..793f1d7 --- /dev/null +++ b/dist/esm/lib/errors/Messages.mjs @@ -0,0 +1,16 @@ +// src/lib/errors/Messages.ts +import { register } from "./HypixelTSError.mjs"; +var messages = { + CLIENT_OPTIONS_MISSING: (option) => `ClientOptions${option ? `.${option}` : ""} ${option ? "is" : "are"} missing`, + CLIENT_OPTION_INVALID_TYPE: (option, type, received) => `ClientOption.${option} is expected to be of type "${type}", received "${received}"`, + GET_UUID_ERROR: (error, code) => `Util.getUUID: Failed with error ${error}, status code ${code}`, + GET_UUID_404: `Util.getUUID: Player not found`, + GET_USERNAME_ERROR: (error, code) => `Util.getUsername: Failed with error ${error}, status code ${code}`, + GET_USERNAME_404: `Util.getUsername: Player not found`, + NOT_UUID: `The supplied string was not of the correct format for a UUID`, + METHOD_MISSING_OPTION: (manager, method, option) => `${manager}.${method}: Required option "${option}" is missing`, + METHOD_INVALID_OPTIONS: (manager, method, option, expected) => `${manager}.${method}: Invalid options provided. Expected type "${expected?.length > 1 ? `either ${expected.join(", ")}` : expected.join(", ")}" for the "${option}" option` +}; +for (const [key, value] of Object.entries(messages)) + register(key, value); +//# sourceMappingURL=Messages.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/errors/Messages.mjs.map b/dist/esm/lib/errors/Messages.mjs.map new file mode 100644 index 0000000..68d6434 --- /dev/null +++ b/dist/esm/lib/errors/Messages.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/errors/Messages.ts"],"sourcesContent":["import { register } from './HypixelTSError';\r\n\r\nconst messages = {\r\n\tCLIENT_OPTIONS_MISSING: (option?: string) => `ClientOptions${option ? `.${option}` : ''} ${option ? 'is' : 'are'} missing`,\r\n\tCLIENT_OPTION_INVALID_TYPE: (option: string, type: string, received?: string) =>\r\n\t\t`ClientOption.${option} is expected to be of type \"${type}\", received \"${received}\"`,\r\n\tGET_UUID_ERROR: (error: string, code: number) => `Util.getUUID: Failed with error ${error}, status code ${code}`,\r\n\tGET_UUID_404: `Util.getUUID: Player not found`,\r\n\tGET_USERNAME_ERROR: (error: string, code: number) => `Util.getUsername: Failed with error ${error}, status code ${code}`,\r\n\tGET_USERNAME_404: `Util.getUsername: Player not found`,\r\n\tNOT_UUID: `The supplied string was not of the correct format for a UUID`,\r\n\tMETHOD_MISSING_OPTION: (manager: string, method: string, option: string) => `${manager}.${method}: Required option \"${option}\" is missing`,\r\n\tMETHOD_INVALID_OPTIONS: (manager: string, method: string, option: string, expected: string[]) =>\r\n\t\t`${manager}.${method}: Invalid options provided. Expected type \"${\r\n\t\t\texpected?.length > 1 ? `either ${expected.join(', ')}` : expected.join(', ')\r\n\t\t}\" for the \"${option}\" option`\r\n};\r\n\r\nfor (const [key, value] of Object.entries(messages)) register(key, value);\r\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,IAAM,WAAW;AAAA,EAChB,wBAAwB,CAAC,WAAoB,gBAAgB,SAAS,IAAI,MAAM,KAAK,EAAE,IAAI,SAAS,OAAO,KAAK;AAAA,EAChH,4BAA4B,CAAC,QAAgB,MAAc,aAC1D,gBAAgB,MAAM,+BAA+B,IAAI,gBAAgB,QAAQ;AAAA,EAClF,gBAAgB,CAAC,OAAe,SAAiB,mCAAmC,KAAK,iBAAiB,IAAI;AAAA,EAC9G,cAAc;AAAA,EACd,oBAAoB,CAAC,OAAe,SAAiB,uCAAuC,KAAK,iBAAiB,IAAI;AAAA,EACtH,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,uBAAuB,CAAC,SAAiB,QAAgB,WAAmB,GAAG,OAAO,IAAI,MAAM,sBAAsB,MAAM;AAAA,EAC5H,wBAAwB,CAAC,SAAiB,QAAgB,QAAgB,aACzE,GAAG,OAAO,IAAI,MAAM,8CACnB,UAAU,SAAS,IAAI,UAAU,SAAS,KAAK,IAAI,CAAC,KAAK,SAAS,KAAK,IAAI,CAC5E,cAAc,MAAM;AACtB;AAEA,WAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ;AAAG,WAAS,KAAK,KAAK;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/errors/index.d.mts b/dist/esm/lib/errors/index.d.mts new file mode 100644 index 0000000..b034152 --- /dev/null +++ b/dist/esm/lib/errors/index.d.mts @@ -0,0 +1 @@ +export { HypixelTSError, register } from './HypixelTSError.mjs'; diff --git a/dist/esm/lib/errors/index.mjs b/dist/esm/lib/errors/index.mjs new file mode 100644 index 0000000..2cd1969 --- /dev/null +++ b/dist/esm/lib/errors/index.mjs @@ -0,0 +1,4 @@ +// src/lib/errors/index.ts +export * from "./HypixelTSError.mjs"; +export * from "./Messages.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/errors/index.mjs.map b/dist/esm/lib/errors/index.mjs.map new file mode 100644 index 0000000..c9ec9c6 --- /dev/null +++ b/dist/esm/lib/errors/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/errors/index.ts"],"sourcesContent":["export * from './HypixelTSError';\r\nexport * from './Messages';\r\n"],"mappings":";AAAA,cAAc;AACd,cAAc;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/index.d.mts b/dist/esm/lib/index.d.mts new file mode 100644 index 0000000..b5764b7 --- /dev/null +++ b/dist/esm/lib/index.d.mts @@ -0,0 +1,2 @@ +export { APIGuild, APIGuildMember, APIGuildRank, APIPlayer, APISkyBlockAuction, APISkyBlockAuctionBanking, APISkyBlockAuctionBankingTransaction, APISkyBlockAuctionBid, APISkyBlockMuseum, APISkyBlockMuseumItem, APISkyBlockMuseumItemItem, APISkyBlockMuseumItemObject, APISkyBlockMuseumMember, APISkyBlockProfile, APISkyBlockProfileMembers, AchievementsResponse, AchievementsResponseAchievement, AchievementsResponseAchievementOnetime, AchievementsResponseAchievementTiered, ActiveNetworkBoostersResponse, ActiveNetworkBoostersResponseActiveBooster, ActiveNetworkBoostersResponseQueuedBooster, ApiRequest, ApiRequestOptions, Base, BaseManager, BaseResourceResponse, ChallengesResponse, ChallengesResponseChallenge, Client, CurrentLeaderboardsResponse, CurrentPlayerCountsResponse, FetchActiveAuctionsResponse, FetchActiveBingoGoalsResponse, FetchActiveBingoGoalsResponseGoal, FetchBazaarResponse, FetchBazaarResponseProduct, FetchBazaarResponseProductBuySummary, FetchBazaarResponseProductQuickStatus, FetchBazaarResponseProductSellSummary, FetchBingoDataResponse, FetchBingoDataResponseEvent, FetchCollectionsResponse, FetchCollectionsResponseCollection, FetchElectionAndMayorResponse, FetchElectionAndMayorResponseCurrent, FetchElectionAndMayorResponseElection, FetchElectionAndMayorResponseElectionCandidate, FetchElectionAndMayorResponseMayor, FetchElectionAndMayorResponseMayorPerks, FetchFireSalesResponse, FetchFireSalesResponseFireSale, FetchItemsResponse, FetchItemsResponseItem, FetchNewsResponse, FetchNewsResponseItem, FetchSkillsResponse, FetchSkillsResponseCollection, FetchSkillsResponseSkill, GameInformationResponse, GameInformationResponseGame, GetRecentlyPlayedGamesResponse, GetStatusResponse, GetUUIDResponse, GetUsernameResponse, Guild, GuildAchievementsResponse, GuildManager, OtherManager, Player, PlayerManager, PunishmentStatisticsResponse, QuestsResponse, QuestsResponseQuest, RecentlyEndedAuctionsResponse, RecentlyEndedAuctionsResponseAuction, RequestManager, ResourceManager, SkyBlockAuction, SkyBlockManager, SkyBlockMuseum, SkyBlockProfile, Util, VanityCompanionsResponse, VanityPetsRarity, VanityPetsResponse, VanityPetsResponseRarity, VanityPetsResponseType } from '../index.mjs'; +export { HypixelAPIError, HypixelAPIErrorResponse } from './rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/index.mjs b/dist/esm/lib/index.mjs new file mode 100644 index 0000000..f978bae --- /dev/null +++ b/dist/esm/lib/index.mjs @@ -0,0 +1,7 @@ +// src/lib/index.ts +export * from "./Client.mjs"; +export * from "./rest/index.mjs"; +export * from "./managers/index.mjs"; +export * from "./classes/index.mjs"; +export * from "./typings/index.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/index.mjs.map b/dist/esm/lib/index.mjs.map new file mode 100644 index 0000000..74820f7 --- /dev/null +++ b/dist/esm/lib/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/lib/index.ts"],"sourcesContent":["export * from './Client';\r\nexport * from './rest/index';\r\nexport * from './managers/index';\r\nexport * from './classes/index';\r\nexport * from './typings/index';\r\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/managers/BaseManager.d.mts b/dist/esm/lib/managers/BaseManager.d.mts new file mode 100644 index 0000000..ca8a3d5 --- /dev/null +++ b/dist/esm/lib/managers/BaseManager.d.mts @@ -0,0 +1,2 @@ +export { BaseManager } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/managers/BaseManager.mjs b/dist/esm/lib/managers/BaseManager.mjs new file mode 100644 index 0000000..c428736 --- /dev/null +++ b/dist/esm/lib/managers/BaseManager.mjs @@ -0,0 +1,35 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/managers/BaseManager.ts +var BaseManager = class { + static { + __name(this, "BaseManager"); + } + /** + * Whether or not the manager requires API key authorization. + */ + requiresAuth; + /** + * The instantiated hypixel.ts client + */ + client; + constructor(client, requiresAuth) { + this.client = client; + this.requiresAuth = requiresAuth; + } + /** + * Calls the request manager to create (and execute) requests to the API. + * + * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers. + * @param path The path/endpoint of the request + * @private + */ + async makeGetRequest(path) { + return this.client.requests.execute(path, this.requiresAuth); + } +}; +export { + BaseManager +}; +//# sourceMappingURL=BaseManager.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/managers/BaseManager.mjs.map b/dist/esm/lib/managers/BaseManager.mjs.map new file mode 100644 index 0000000..7d3715a --- /dev/null +++ b/dist/esm/lib/managers/BaseManager.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/BaseManager.ts"],"sourcesContent":["import type { Client } from '../Client';\r\n\r\n/**\r\n * The base manager which all other managers extend from\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class BaseManager {\r\n\t/**\r\n\t * Whether or not the manager requires API key authorization.\r\n\t */\r\n\tprotected requiresAuth: boolean;\r\n\r\n\t/**\r\n\t * The instantiated hypixel.ts client\r\n\t */\r\n\tprotected client: Client;\r\n\r\n\tpublic constructor(client: Client, requiresAuth: boolean) {\r\n\t\tthis.client = client;\r\n\t\tthis.requiresAuth = requiresAuth;\r\n\t}\r\n\r\n\t/**\r\n\t * Calls the request manager to create (and execute) requests to the API.\r\n\t *\r\n\t * **NOTE**: Do not directly use this method unless you know what you are doing. Consider using the methods provided in the managers.\r\n\t * @param path The path/endpoint of the request\r\n\t * @private\r\n\t */\r\n\tprotected async makeGetRequest(path: string) {\r\n\t\treturn this.client.requests.execute(path, this.requiresAuth);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAOO,IAAM,cAAN,MAAkB;AAAA,EAPzB,OAOyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAId;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEH,YAAY,QAAgB,cAAuB;AACzD,SAAK,SAAS;AACd,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAgB,eAAkB,MAAc;AAC/C,WAAO,KAAK,OAAO,SAAS,QAAW,MAAM,KAAK,YAAY;AAAA,EAC/D;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/managers/GuildManager.d.mts b/dist/esm/lib/managers/GuildManager.d.mts new file mode 100644 index 0000000..24684ad --- /dev/null +++ b/dist/esm/lib/managers/GuildManager.d.mts @@ -0,0 +1,2 @@ +export { GuildManager } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/managers/GuildManager.mjs b/dist/esm/lib/managers/GuildManager.mjs new file mode 100644 index 0000000..14778d7 --- /dev/null +++ b/dist/esm/lib/managers/GuildManager.mjs @@ -0,0 +1,34 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/managers/GuildManager.ts +import { BaseManager } from "./BaseManager.mjs"; +import { HypixelTSError } from "../errors/HypixelTSError.mjs"; +import { Guild } from "../classes/Guild.mjs"; +var GuildManager = class extends BaseManager { + static { + __name(this, "GuildManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid + * @param identifier The id/name of the guild or the uuid of the player + * @param type The type of identifier you're passing (id/name of guild, player uuid) + */ + async fetch(identifier, type) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "GuildManager", "fetch", "type"); + if (type !== "id" && type !== "name" && type !== "player") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "GuildManager", "fetch", "type", ["id", "name", "player"]); + const { guild } = await this.makeGetRequest(`/guild?${type}=${identifier}`); + return guild ? new Guild(this.client, guild) : null; + } +}; +export { + GuildManager +}; +//# sourceMappingURL=GuildManager.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/managers/GuildManager.mjs.map b/dist/esm/lib/managers/GuildManager.mjs.map new file mode 100644 index 0000000..3f71da8 --- /dev/null +++ b/dist/esm/lib/managers/GuildManager.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/GuildManager.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/HypixelTSError';\r\nimport { Guild } from '../classes/Guild';\r\nimport type { APIGuild } from '../typings';\r\nimport type { Client } from '../Client';\r\n\r\n/**\r\n * Guild related endpoints\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class GuildManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a guild by the guild id, or its name, or a player's guild by providing their uuid\r\n\t * @param identifier The id/name of the guild or the uuid of the player\r\n\t * @param type The type of identifier you're passing (id/name of guild, player uuid)\r\n\t */\r\n\tpublic async fetch(identifier: string, type: 'id' | 'name' | 'player') {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'GuildManager', 'fetch', 'type');\r\n\t\tif (type !== 'id' && type !== 'name' && type !== 'player')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'GuildManager', 'fetch', 'type', ['id', 'name', 'player']);\r\n\r\n\t\tconst { guild } = await this.makeGetRequest<{ guild: APIGuild | null }>(`/guild?${type}=${identifier}`);\r\n\t\treturn guild ? new Guild(this.client, guild) : null;\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,aAAa;AASf,IAAM,eAAN,cAA2B,YAAY;AAAA,EAX9C,OAW8C;AAAA;AAAA;AAAA,EACtC,YAAY,QAAgB;AAClC,UAAM,QAAQ,IAAI;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,MAAM,YAAoB,MAAgC;AACtE,QAAI,CAAC;AAAY,YAAM,IAAI,eAAe,yBAAyB,gBAAgB,SAAS,YAAY;AACxG,QAAI,CAAC;AAAM,YAAM,IAAI,eAAe,yBAAyB,gBAAgB,SAAS,MAAM;AAC5F,QAAI,SAAS,QAAQ,SAAS,UAAU,SAAS;AAChD,YAAM,IAAI,eAAe,0BAA0B,gBAAgB,SAAS,QAAQ,CAAC,MAAM,QAAQ,QAAQ,CAAC;AAE7G,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,eAA2C,UAAU,IAAI,IAAI,UAAU,EAAE;AACtG,WAAO,QAAQ,IAAI,MAAM,KAAK,QAAQ,KAAK,IAAI;AAAA,EAChD;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/managers/OtherManager.d.mts b/dist/esm/lib/managers/OtherManager.d.mts new file mode 100644 index 0000000..2065247 --- /dev/null +++ b/dist/esm/lib/managers/OtherManager.d.mts @@ -0,0 +1,2 @@ +export { OtherManager } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/managers/OtherManager.mjs b/dist/esm/lib/managers/OtherManager.mjs new file mode 100644 index 0000000..9853c1c --- /dev/null +++ b/dist/esm/lib/managers/OtherManager.mjs @@ -0,0 +1,59 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/managers/OtherManager.ts +import { BaseManager } from "./BaseManager.mjs"; +var OtherManager = class extends BaseManager { + static { + __name(this, "OtherManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch all active network boosters + */ + async fetchActiveNetworkBoosters() { + const data = await this.makeGetRequest("/boosters"); + return { + boosters: data.boosters, + boosterState: data.boosterState + }; + } + /** + * Fetch current player counts across all games + */ + async fetchCurrentPlayerCounts() { + const data = await this.makeGetRequest("/counts"); + return { + playerCount: data.playerCount, + games: data.games + }; + } + /** + * Fetch current leaderboards + */ + async fetchCurrentLeaderboards() { + const data = await this.makeGetRequest("/leaderboards"); + return { + leaderboards: data.leaderboards + }; + } + /** + * Fetch punishment statistics + */ + async fetchPunishmentStatistics() { + const data = await this.makeGetRequest("/punishmentstats"); + return { + watchdog_lastMinute: data.watchdog_lastMinute, + staff_rollingDaily: data.staff_rollingDaily, + watchdog_total: data.watchdog_total, + watchdog_rollingDaily: data.watchdog_rollingDaily, + staff_total: data.staff_total + }; + } +}; +export { + OtherManager +}; +//# sourceMappingURL=OtherManager.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/managers/OtherManager.mjs.map b/dist/esm/lib/managers/OtherManager.mjs.map new file mode 100644 index 0000000..37493f2 --- /dev/null +++ b/dist/esm/lib/managers/OtherManager.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/OtherManager.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport type {\r\n\tActiveNetworkBoostersResponse,\r\n\tCurrentPlayerCountsResponse,\r\n\tCurrentLeaderboardsResponse,\r\n\tPunishmentStatisticsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Other endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/Other}\r\n */\r\nexport class OtherManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all active network boosters\r\n\t */\r\n\tpublic async fetchActiveNetworkBoosters(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/boosters');\r\n\t\treturn {\r\n\t\t\tboosters: data.boosters,\r\n\t\t\tboosterState: data.boosterState\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current player counts across all games\r\n\t */\r\n\tpublic async fetchCurrentPlayerCounts(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/counts');\r\n\t\treturn {\r\n\t\t\tplayerCount: data.playerCount,\r\n\t\t\tgames: data.games\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch current leaderboards\r\n\t */\r\n\tpublic async fetchCurrentLeaderboards(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/leaderboards');\r\n\t\treturn {\r\n\t\t\tleaderboards: data.leaderboards\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch punishment statistics\r\n\t */\r\n\tpublic async fetchPunishmentStatistics(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/punishmentstats');\r\n\t\treturn {\r\n\t\t\twatchdog_lastMinute: data.watchdog_lastMinute,\r\n\t\t\tstaff_rollingDaily: data.staff_rollingDaily,\r\n\t\t\twatchdog_total: data.watchdog_total,\r\n\t\t\twatchdog_rollingDaily: data.watchdog_rollingDaily,\r\n\t\t\tstaff_total: data.staff_total\r\n\t\t};\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,mBAAmB;AAerB,IAAM,eAAN,cAA2B,YAAY;AAAA,EAf9C,OAe8C;AAAA;AAAA;AAAA,EACtC,YAAY,QAAgB;AAClC,UAAM,QAAQ,IAAI;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,6BAAqE;AACjF,UAAM,OAAO,MAAM,KAAK,eAA8C,WAAW;AACjF,WAAO;AAAA,MACN,UAAU,KAAK;AAAA,MACf,cAAc,KAAK;AAAA,IACpB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,2BAAiE;AAC7E,UAAM,OAAO,MAAM,KAAK,eAA4C,SAAS;AAC7E,WAAO;AAAA,MACN,aAAa,KAAK;AAAA,MAClB,OAAO,KAAK;AAAA,IACb;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,2BAAiE;AAC7E,UAAM,OAAO,MAAM,KAAK,eAA4C,eAAe;AACnF,WAAO;AAAA,MACN,cAAc,KAAK;AAAA,IACpB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,4BAAmE;AAC/E,UAAM,OAAO,MAAM,KAAK,eAA6C,kBAAkB;AACvF,WAAO;AAAA,MACN,qBAAqB,KAAK;AAAA,MAC1B,oBAAoB,KAAK;AAAA,MACzB,gBAAgB,KAAK;AAAA,MACrB,uBAAuB,KAAK;AAAA,MAC5B,aAAa,KAAK;AAAA,IACnB;AAAA,EACD;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/managers/PlayerManager.d.mts b/dist/esm/lib/managers/PlayerManager.d.mts new file mode 100644 index 0000000..17a46fc --- /dev/null +++ b/dist/esm/lib/managers/PlayerManager.d.mts @@ -0,0 +1,2 @@ +export { PlayerManager } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/managers/PlayerManager.mjs b/dist/esm/lib/managers/PlayerManager.mjs new file mode 100644 index 0000000..96eaa36 --- /dev/null +++ b/dist/esm/lib/managers/PlayerManager.mjs @@ -0,0 +1,64 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/managers/PlayerManager.ts +import { BaseManager } from "./BaseManager.mjs"; +import { Player, Util } from "../classes/index.mjs"; +import { HypixelTSError } from "../errors/index.mjs"; +var PlayerManager = class extends BaseManager { + static { + __name(this, "PlayerManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch a player using their username or uuid + * @param identifier The username/uuid of the player + */ + async fetch(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "fetch", "identifier"); + const uuid = await this.getUUID(identifier); + const { player } = await this.makeGetRequest(`/player?uuid=${uuid}`); + return new Player(this.client, player); + } + /** + * Fetch the recently played games of a player + * @param identifier The username/uuid of the player + */ + async getRecentlyPlayedGames(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getRecentlyPlayedGames", "identifier"); + const uuid = await this.getUUID(identifier); + const { games } = await this.makeGetRequest(`/recentgames?uuid=${uuid}`); + return games; + } + /** + * Fetch the status of a player + * @param identifier The username/uuid of the player + */ + async getStatus(identifier) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "PlayerManager", "getStatus", "identifier"); + const uuid = await this.getUUID(identifier); + const { session } = await this.makeGetRequest(`/status?uuid=${uuid}`); + return session; + } + /** + * Resolves the username to a uuid for use in requests + * @param identifier The username (or uuid) of the player + */ + async getUUID(identifier) { + const isUUID = Util.isUUID(identifier); + if (!isUUID) { + const uuid = await Util.getUUID(identifier); + return uuid; + } + return identifier; + } +}; +export { + PlayerManager +}; +//# sourceMappingURL=PlayerManager.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/managers/PlayerManager.mjs.map b/dist/esm/lib/managers/PlayerManager.mjs.map new file mode 100644 index 0000000..6b5ce87 --- /dev/null +++ b/dist/esm/lib/managers/PlayerManager.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/PlayerManager.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport { Client } from '../Client';\r\nimport { Player, Util } from '../classes/index';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport type { APIPlayer, GetRecentlyPlayedGamesResponse, GetStatusResponse } from '../typings';\r\n\r\n/**\r\n * Player related endpoints.\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class PlayerManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a player using their username or uuid\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async fetch(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'fetch', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { player } = await this.makeGetRequest<{ player: APIPlayer }>(`/player?uuid=${uuid}`);\r\n\t\treturn new Player(this.client, player);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the recently played games of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getRecentlyPlayedGames(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getRecentlyPlayedGames', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { games } = await this.makeGetRequest<{ games: GetRecentlyPlayedGamesResponse[] }>(`/recentgames?uuid=${uuid}`);\r\n\t\treturn games;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the status of a player\r\n\t * @param identifier The username/uuid of the player\r\n\t */\r\n\tpublic async getStatus(identifier: string) {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'PlayerManager', 'getStatus', 'identifier');\r\n\r\n\t\tconst uuid = await this.getUUID(identifier);\r\n\t\tconst { session } = await this.makeGetRequest<{ session: GetStatusResponse }>(`/status?uuid=${uuid}`);\r\n\t\treturn session;\r\n\t}\r\n\r\n\t/**\r\n\t * Resolves the username to a uuid for use in requests\r\n\t * @param identifier The username (or uuid) of the player\r\n\t */\r\n\tprivate async getUUID(identifier: string) {\r\n\t\tconst isUUID = Util.isUUID(identifier);\r\n\r\n\t\tif (!isUUID) {\r\n\t\t\tconst uuid = await Util.getUUID(identifier);\r\n\t\t\treturn uuid;\r\n\t\t}\r\n\r\n\t\treturn identifier;\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,mBAAmB;AAE5B,SAAS,QAAQ,YAAY;AAC7B,SAAS,sBAAsB;AAQxB,IAAM,gBAAN,cAA4B,YAAY;AAAA,EAX/C,OAW+C;AAAA;AAAA;AAAA,EACvC,YAAY,QAAgB;AAClC,UAAM,QAAQ,IAAI;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,MAAM,YAAoB;AACtC,QAAI,CAAC;AAAY,YAAM,IAAI,eAAe,yBAAyB,iBAAiB,SAAS,YAAY;AAEzG,UAAM,OAAO,MAAM,KAAK,QAAQ,UAAU;AAC1C,UAAM,EAAE,OAAO,IAAI,MAAM,KAAK,eAAsC,gBAAgB,IAAI,EAAE;AAC1F,WAAO,IAAI,OAAO,KAAK,QAAQ,MAAM;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,uBAAuB,YAAoB;AACvD,QAAI,CAAC;AAAY,YAAM,IAAI,eAAe,yBAAyB,iBAAiB,0BAA0B,YAAY;AAE1H,UAAM,OAAO,MAAM,KAAK,QAAQ,UAAU;AAC1C,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,eAA4D,qBAAqB,IAAI,EAAE;AACpH,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,UAAU,YAAoB;AAC1C,QAAI,CAAC;AAAY,YAAM,IAAI,eAAe,yBAAyB,iBAAiB,aAAa,YAAY;AAE7G,UAAM,OAAO,MAAM,KAAK,QAAQ,UAAU;AAC1C,UAAM,EAAE,QAAQ,IAAI,MAAM,KAAK,eAA+C,gBAAgB,IAAI,EAAE;AACpG,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,QAAQ,YAAoB;AACzC,UAAM,SAAS,KAAK,OAAO,UAAU;AAErC,QAAI,CAAC,QAAQ;AACZ,YAAM,OAAO,MAAM,KAAK,QAAQ,UAAU;AAC1C,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/managers/ResourceManager.d.mts b/dist/esm/lib/managers/ResourceManager.d.mts new file mode 100644 index 0000000..5f6e7a9 --- /dev/null +++ b/dist/esm/lib/managers/ResourceManager.d.mts @@ -0,0 +1,2 @@ +export { ResourceManager } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/managers/ResourceManager.mjs b/dist/esm/lib/managers/ResourceManager.mjs new file mode 100644 index 0000000..1a1d6c8 --- /dev/null +++ b/dist/esm/lib/managers/ResourceManager.mjs @@ -0,0 +1,59 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/managers/ResourceManager.ts +import { BaseManager } from "./BaseManager.mjs"; +var ResourceManager = class extends BaseManager { + static { + __name(this, "ResourceManager"); + } + constructor(client) { + super(client, false); + } + /** + * Fetch information about Hypixel games + */ + async fetchGameInformation() { + return this.makeGetRequest("/resources/games"); + } + /** + * Fetch all achievements + */ + async fetchAchievements() { + return this.makeGetRequest("/resources/achievements"); + } + /** + * Fetch all challenges + */ + async fetchChallenges() { + return this.makeGetRequest("/resources/challenges"); + } + /** + * Fetch all quests + */ + async fetchQuests() { + return this.makeGetRequest("/resources/quests"); + } + /** + * Fetch all guild achievements + */ + async fetchGuildAchievements() { + return this.makeGetRequest("/resources/guilds/achievements"); + } + /** + * Fetch all vanity pets + */ + async fetchVanityPets() { + return this.makeGetRequest("/resources/vanity/pets"); + } + /** + * Fetch all vanity companions + */ + async fetchVanityCompanions() { + return this.makeGetRequest("/resources/vanity/companions"); + } +}; +export { + ResourceManager +}; +//# sourceMappingURL=ResourceManager.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/managers/ResourceManager.mjs.map b/dist/esm/lib/managers/ResourceManager.mjs.map new file mode 100644 index 0000000..f0cd01a --- /dev/null +++ b/dist/esm/lib/managers/ResourceManager.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/ResourceManager.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport type { Client } from '../Client';\r\nimport type {\r\n\tVanityPetsResponse,\r\n\tAchievementsResponse,\r\n\tChallengesResponse,\r\n\tGameInformationResponse,\r\n\tGuildAchievementsResponse,\r\n\tQuestsResponse,\r\n\tVanityCompanionsResponse\r\n} from '../typings';\r\n\r\n/**\r\n * Resource endpoints.\r\n *\r\n * **Note**: API Key authorization is not required to use this manager.\r\n *\r\n * @category Managers\r\n * @group Managers\r\n */\r\nexport class ResourceManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, false);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information about Hypixel games\r\n\t */\r\n\tpublic async fetchGameInformation() {\r\n\t\treturn this.makeGetRequest('/resources/games');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all achievements\r\n\t */\r\n\tpublic async fetchAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all challenges\r\n\t */\r\n\tpublic async fetchChallenges() {\r\n\t\treturn this.makeGetRequest('/resources/challenges');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all quests\r\n\t */\r\n\tpublic async fetchQuests() {\r\n\t\treturn this.makeGetRequest('/resources/quests');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all guild achievements\r\n\t */\r\n\tpublic async fetchGuildAchievements() {\r\n\t\treturn this.makeGetRequest('/resources/guilds/achievements');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity pets\r\n\t */\r\n\tpublic async fetchVanityPets() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/pets');\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch all vanity companions\r\n\t */\r\n\tpublic async fetchVanityCompanions() {\r\n\t\treturn this.makeGetRequest('/resources/vanity/companions');\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,mBAAmB;AAoBrB,IAAM,kBAAN,cAA8B,YAAY;AAAA,EApBjD,OAoBiD;AAAA;AAAA;AAAA,EACzC,YAAY,QAAgB;AAClC,UAAM,QAAQ,KAAK;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,uBAAuB;AACnC,WAAO,KAAK,eAAwC,kBAAkB;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,oBAAoB;AAChC,WAAO,KAAK,eAAqC,yBAAyB;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,kBAAkB;AAC9B,WAAO,KAAK,eAAmC,uBAAuB;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,cAAc;AAC1B,WAAO,KAAK,eAA+B,mBAAmB;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,yBAAyB;AACrC,WAAO,KAAK,eAA0C,gCAAgC;AAAA,EACvF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,kBAAkB;AAC9B,WAAO,KAAK,eAAmC,wBAAwB;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,wBAAwB;AACpC,WAAO,KAAK,eAAyC,8BAA8B;AAAA,EACpF;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/managers/SkyBlockManager.d.mts b/dist/esm/lib/managers/SkyBlockManager.d.mts new file mode 100644 index 0000000..8e0b9a5 --- /dev/null +++ b/dist/esm/lib/managers/SkyBlockManager.d.mts @@ -0,0 +1,2 @@ +export { SkyBlockManager } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/managers/SkyBlockManager.mjs b/dist/esm/lib/managers/SkyBlockManager.mjs new file mode 100644 index 0000000..ffca8a9 --- /dev/null +++ b/dist/esm/lib/managers/SkyBlockManager.mjs @@ -0,0 +1,209 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/managers/SkyBlockManager.ts +import { BaseManager } from "./BaseManager.mjs"; +import { HypixelTSError } from "../errors/index.mjs"; +import { SkyBlockProfile, SkyBlockAuction, SkyBlockMuseum } from "../classes/index.mjs"; +var SkyBlockManager = class extends BaseManager { + static { + __name(this, "SkyBlockManager"); + } + constructor(client) { + super(client, true); + } + /** + * Fetch information regarding collections in the SkyBlock game + */ + async fetchCollections() { + const data = await this.makeGetRequest("/resources/skyblock/collections"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections + }; + } + /** + * Fetch information regarding skills in the SkyBlock game + */ + async fetchSkills() { + const data = await this.makeGetRequest("/resources/skyblock/skills"); + return { + lastUpdated: data.lastUpdated, + version: data.version, + collections: data.collections, + skills: data.skills + }; + } + /** + * Fetch information regarding items in the SkyBlock game + */ + async fetchItems() { + const data = await this.makeGetRequest("/resources/skyblock/items"); + return { + lastUpdated: data.lastUpdated, + items: data.items + }; + } + /** + * Fetch information regarding the current mayor and ongoing election in SkyBlock + */ + async fetchElectionAndMayor() { + const data = await this.makeGetRequest("/resources/skyblock/election"); + return { + lastUpdated: data.lastUpdated, + mayor: data.mayor, + current: data.current + }; + } + /** + * Fetch information regarding the current bingo event and its goals + */ + async fetchActiveBingoGoals() { + const data = await this.makeGetRequest("/resources/skyblock/bingo"); + return { + lastUpdated: data.lastUpdated, + id: data.id, + goals: data.goals + }; + } + /** + * Fetch SkyBlock news + */ + async fetchNews() { + const data = await this.makeGetRequest("/skyblock/news"); + return { + items: data.items + }; + } + /** + * Fetch a SkyBlock auction. + * @param identifier The idenitifer you're using to fetch the auction + * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`) + * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`. + */ + async fetchAuction(identifier, type, raw = false) { + if (!identifier) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "identifier"); + if (!type) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchAuction", "type"); + if (type !== "uuid" && type !== "player" && type !== "profile") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchAuction", "type", ["uuid", "player", "profile"]); + const { auctions } = await this.makeGetRequest(`/skyblock/auction?${type}=${identifier}`); + if (!raw) { + const parsed = []; + for (const auction of auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return parsed; + } + return auctions; + } + /** + * Fetch the currently active auctions (sorted by last updated first and paginated) + * @param page The page number + * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`. + */ + async fetchActiveAuctions(page, resolveAuctions = true) { + if (page && typeof page !== "number") + throw new HypixelTSError("METHOD_INVALID_OPTIONS", "SkyBlockManager", "fetchActiveAuctions", "page", ["number"]); + const data = await this.makeGetRequest(`/skyblock/auctions${page ? "?page=" + page : ""}`); + if (resolveAuctions) { + const parsed = []; + for (const auction of data.auctions) { + parsed.push(new SkyBlockAuction(this.client, auction)); + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: parsed + }; + } + return { + lastUpdated: data.lastUpdated, + page: data.page, + totalPages: data.totalPages, + totalAuctions: data.totalAuctions, + auctions: data.auctions + }; + } + /** + * Fetch recently ended auctions (auctions which ended in the last 60 seconds). + */ + async fetchRecentlyEndedAuctions() { + const data = await this.makeGetRequest("/skyblock/auctions_ended"); + return { + lastUpdated: data.lastUpdated, + auctions: data.auctions + }; + } + /** + * Fetch bazaar items + */ + async fetchBazaar() { + const data = await this.makeGetRequest("/skyblock/bazaar"); + return { + lastUpdated: data.lastUpdated, + products: data.products + }; + } + /** + * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchProfile(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchProfile", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`); + return new SkyBlockProfile(this.client, data); + } + /** + * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + async fetchMuseum(profileUuid) { + if (!profileUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchMuseum", "profileUuid"); + const data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`); + return new SkyBlockMuseum(this.client, data); + } + /** + * Fetch a SkyBlock profiles of a player + * @param playerUuid The uuid of the player + */ + async fetchPlayerSkyBlockProfiles(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchPlayerSkyBlockProfiles", "playerUuid"); + const { profiles } = await this.makeGetRequest(`/skyblock/profiles?uuid=${playerUuid}`); + const parsed = []; + for (const profile of profiles) { + parsed.push(new SkyBlockProfile(this.client, profile)); + } + return parsed; + } + /** + * Fetch bingo data of a player + * @param playerUuid The uuid of the player + */ + async fetchBingoData(playerUuid) { + if (!playerUuid) + throw new HypixelTSError("METHOD_MISSING_OPTION", "SkyBlockManager", "fetchBingoData", "playerUuid"); + const data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`); + return { + events: data.events + }; + } + /** + * Fetch the currently active or upcoming Fire Sales for SkyBlock + */ + async fetchFireSales() { + const { sales } = await this.makeGetRequest("/skyblock/firesales"); + return sales; + } +}; +export { + SkyBlockManager +}; +//# sourceMappingURL=SkyBlockManager.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/managers/SkyBlockManager.mjs.map b/dist/esm/lib/managers/SkyBlockManager.mjs.map new file mode 100644 index 0000000..b854736 --- /dev/null +++ b/dist/esm/lib/managers/SkyBlockManager.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/SkyBlockManager.ts"],"sourcesContent":["import { BaseManager } from './BaseManager';\r\nimport { HypixelTSError } from '../errors/index';\r\nimport { SkyBlockProfile, SkyBlockAuction, SkyBlockMuseum } from '../classes/index';\r\nimport type { Client } from '../Client';\r\nimport {\r\n\ttype APISkyBlockProfile,\r\n\ttype FetchCollectionsResponse,\r\n\ttype FetchSkillsResponse,\r\n\ttype FetchItemsResponse,\r\n\ttype FetchElectionAndMayorResponse,\r\n\ttype FetchActiveBingoGoalsResponse,\r\n\ttype FetchNewsResponse,\r\n\ttype APISkyBlockAuction,\r\n\ttype FetchActiveAuctionsResponse,\r\n\ttype FetchBazaarResponse,\r\n\ttype RecentlyEndedAuctionsResponse,\r\n\ttype FetchBingoDataResponse,\r\n\ttype FetchFireSalesResponse,\r\n\ttype FetchFireSalesResponseFireSale,\r\n\tAPISkyBlockMuseum\r\n} from '../typings';\r\n\r\n/**\r\n * Skyblock related endpoints\r\n * @category Managers\r\n * @group Managers\r\n * @see {@link https://api.hypixel.net/#tag/SkyBlock}\r\n */\r\nexport class SkyBlockManager extends BaseManager {\r\n\tpublic constructor(client: Client) {\r\n\t\tsuper(client, true);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding collections in the SkyBlock game\r\n\t */\r\n\tpublic async fetchCollections(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/collections');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding skills in the SkyBlock game\r\n\t */\r\n\tpublic async fetchSkills(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/skills');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tversion: data.version,\r\n\t\t\tcollections: data.collections,\r\n\t\t\tskills: data.skills\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding items in the SkyBlock game\r\n\t */\r\n\tpublic async fetchItems(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/items');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current mayor and ongoing election in SkyBlock\r\n\t */\r\n\tpublic async fetchElectionAndMayor(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/election');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tmayor: data.mayor,\r\n\t\t\tcurrent: data.current\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch information regarding the current bingo event and its goals\r\n\t */\r\n\tpublic async fetchActiveBingoGoals(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/resources/skyblock/bingo');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tid: data.id,\r\n\t\t\tgoals: data.goals\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch SkyBlock news\r\n\t */\r\n\tpublic async fetchNews() {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/news');\r\n\t\treturn {\r\n\t\t\titems: data.items\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock auction.\r\n\t * @param identifier The idenitifer you're using to fetch the auction\r\n\t * @param type The type of identifier you're passing (either auction `uuid`, uuid of the `player`, uuid of the `profile`)\r\n\t * @param raw Whether to return the raw response, without converting each auction to an @see{@link SkyBlockAuction} class. Defaults to `false`.\r\n\t */\r\n\tpublic async fetchAuction(\r\n\t\tidentifier: string,\r\n\t\ttype: 'uuid' | 'player' | 'profile',\r\n\t\traw = false\r\n\t): Promise {\r\n\t\tif (!identifier) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'identifier');\r\n\t\tif (!type) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchAuction', 'type');\r\n\t\tif (type !== 'uuid' && type !== 'player' && type !== 'profile')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchAuction', 'type', ['uuid', 'player', 'profile']);\r\n\r\n\t\tconst { auctions } = await this.makeGetRequest<{ auctions: APISkyBlockAuction[] }>(`/skyblock/auction?${type}=${identifier}`);\r\n\r\n\t\tif (!raw) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn parsed;\r\n\t\t}\r\n\r\n\t\treturn auctions;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active auctions (sorted by last updated first and paginated)\r\n\t * @param page The page number\r\n\t * @param resolveAuctions Whether to resolve the auctions returned, to a @see {@link SkyBlockAuction} class. Defaults to `true`.\r\n\t */\r\n\tpublic async fetchActiveAuctions(page?: number, resolveAuctions = true) {\r\n\t\tif (page && typeof page !== 'number')\r\n\t\t\tthrow new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchActiveAuctions', 'page', ['number']);\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/auctions${page ? '?page=' + page : ''}`);\r\n\r\n\t\tif (resolveAuctions) {\r\n\t\t\tconst parsed = [];\r\n\r\n\t\t\tfor (const auction of data.auctions) {\r\n\t\t\t\tparsed.push(new SkyBlockAuction(this.client, auction));\r\n\t\t\t}\r\n\r\n\t\t\treturn {\r\n\t\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\t\tpage: data.page,\r\n\t\t\t\ttotalPages: data.totalPages,\r\n\t\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\t\tauctions: parsed\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tpage: data.page,\r\n\t\t\ttotalPages: data.totalPages,\r\n\t\t\ttotalAuctions: data.totalAuctions,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch recently ended auctions (auctions which ended in the last 60 seconds).\r\n\t */\r\n\tpublic async fetchRecentlyEndedAuctions(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/auctions_ended');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tauctions: data.auctions\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bazaar items\r\n\t */\r\n\tpublic async fetchBazaar(): Promise {\r\n\t\tconst data = await this.makeGetRequest('/skyblock/bazaar');\r\n\t\treturn {\r\n\t\t\tlastUpdated: data.lastUpdated,\r\n\t\t\tproducts: data.products\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profile (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchProfile(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchProfile', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/profile?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockProfile(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings.\r\n\t * @param profileUuid The uuid of the SkyBlock profile\r\n\t */\r\n\tpublic async fetchMuseum(profileUuid: string): Promise {\r\n\t\tif (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchMuseum', 'profileUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`);\r\n\r\n\t\treturn new SkyBlockMuseum(this.client, data);\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch a SkyBlock profiles of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchPlayerSkyBlockProfiles(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchPlayerSkyBlockProfiles', 'playerUuid');\r\n\r\n\t\tconst { profiles } = await this.makeGetRequest<{ profiles: APISkyBlockProfile[] }>(`/skyblock/profiles?uuid=${playerUuid}`);\r\n\t\tconst parsed = [];\r\n\r\n\t\tfor (const profile of profiles) {\r\n\t\t\tparsed.push(new SkyBlockProfile(this.client, profile));\r\n\t\t}\r\n\r\n\t\treturn parsed;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch bingo data of a player\r\n\t * @param playerUuid The uuid of the player\r\n\t */\r\n\tpublic async fetchBingoData(playerUuid: string): Promise {\r\n\t\tif (!playerUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchBingoData', 'playerUuid');\r\n\r\n\t\tconst data = await this.makeGetRequest(`/skyblock/bingo?uuid=${playerUuid}`);\r\n\t\treturn {\r\n\t\t\tevents: data.events\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Fetch the currently active or upcoming Fire Sales for SkyBlock\r\n\t */\r\n\tpublic async fetchFireSales(): Promise {\r\n\t\tconst { sales } = await this.makeGetRequest('/skyblock/firesales');\r\n\t\treturn sales;\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB,iBAAiB,sBAAsB;AA0B1D,IAAM,kBAAN,cAA8B,YAAY;AAAA,EA5BjD,OA4BiD;AAAA;AAAA;AAAA,EACzC,YAAY,QAAgB;AAClC,UAAM,QAAQ,IAAI;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,mBAAsD;AAClE,UAAM,OAAO,MAAM,KAAK,eAAyC,iCAAiC;AAClG,WAAO;AAAA,MACN,aAAa,KAAK;AAAA,MAClB,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,IACnB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,cAA4C;AACxD,UAAM,OAAO,MAAM,KAAK,eAAoC,4BAA4B;AACxF,WAAO;AAAA,MACN,aAAa,KAAK;AAAA,MAClB,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IACd;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,aAA0C;AACtD,UAAM,OAAO,MAAM,KAAK,eAAmC,2BAA2B;AACtF,WAAO;AAAA,MACN,aAAa,KAAK;AAAA,MAClB,OAAO,KAAK;AAAA,IACb;AAA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AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,YAAY,aAA8C;AACtE,QAAI,CAAC;AAAa,YAAM,IAAI,eAAe,yBAAyB,mBAAmB,eAAe,aAAa;AAEnH,UAAM,OAAO,MAAM,KAAK,eAAkC,4BAA4B,WAAW,EAAE;AAEnG,WAAO,IAAI,eAAe,KAAK,QAAQ,IAAI;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,4BAA4B,YAAgD;AACxF,QAAI,CAAC;AAAY,YAAM,IAAI,eAAe,yBAAyB,mBAAmB,+BAA+B,YAAY;AAEjI,UAAM,EAAE,SAAS,IAAI,MAAM,KAAK,eAAmD,2BAA2B,UAAU,EAAE;AAC1H,UAAM,SAAS,CAAC;AAEhB,eAAW,WAAW,UAAU;AAC/B,aAAO,KAAK,IAAI,gBAAgB,KAAK,QAAQ,OAAO,CAAC;AAAA,IACtD;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,eAAe,YAAqD;AAChF,QAAI,CAAC;AAAY,YAAM,IAAI,eAAe,yBAAyB,mBAAmB,kBAAkB,YAAY;AAEpH,UAAM,OAAO,MAAM,KAAK,eAAuC,wBAAwB,UAAU,EAAE;AACnG,WAAO;AAAA,MACN,QAAQ,KAAK;AAAA,IACd;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,iBAA4D;AACxE,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,eAAuC,qBAAqB;AACzF,WAAO;AAAA,EACR;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/managers/index.d.mts b/dist/esm/lib/managers/index.d.mts new file mode 100644 index 0000000..7f667d3 --- /dev/null +++ b/dist/esm/lib/managers/index.d.mts @@ -0,0 +1,2 @@ +export { BaseManager, GuildManager, OtherManager, PlayerManager, ResourceManager, SkyBlockManager } from '../../index.mjs'; +import '../rest/HypixelAPIError.mjs'; diff --git a/dist/esm/lib/managers/index.mjs b/dist/esm/lib/managers/index.mjs new file mode 100644 index 0000000..d70b4cc --- /dev/null +++ b/dist/esm/lib/managers/index.mjs @@ -0,0 +1,8 @@ +// src/lib/managers/index.ts +export * from "./BaseManager.mjs"; +export * from "./GuildManager.mjs"; +export * from "./OtherManager.mjs"; +export * from "./PlayerManager.mjs"; +export * from "./ResourceManager.mjs"; +export * from "./SkyBlockManager.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/managers/index.mjs.map b/dist/esm/lib/managers/index.mjs.map new file mode 100644 index 0000000..f6fa924 --- /dev/null +++ b/dist/esm/lib/managers/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/managers/index.ts"],"sourcesContent":["export * from './BaseManager';\r\n\r\nexport * from './GuildManager';\r\nexport * from './OtherManager';\r\nexport * from './PlayerManager';\r\nexport * from './ResourceManager';\r\nexport * from './SkyBlockManager';\r\n"],"mappings":";AAAA,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/rest/ApiRequest.d.mts b/dist/esm/lib/rest/ApiRequest.d.mts new file mode 100644 index 0000000..55f3540 --- /dev/null +++ b/dist/esm/lib/rest/ApiRequest.d.mts @@ -0,0 +1,2 @@ +export { ApiRequest, ApiRequestOptions } from '../../index.mjs'; +import './HypixelAPIError.mjs'; diff --git a/dist/esm/lib/rest/ApiRequest.mjs b/dist/esm/lib/rest/ApiRequest.mjs new file mode 100644 index 0000000..60d37de --- /dev/null +++ b/dist/esm/lib/rest/ApiRequest.mjs @@ -0,0 +1,61 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/rest/ApiRequest.ts +import { HypixelAPIError } from "./index.mjs"; +import { HypixelTSError } from "../errors/index.mjs"; +var ApiRequest = class { + static { + __name(this, "ApiRequest"); + } + /** + * The request manager instance + */ + requests; + /** + * The options of this request + */ + options; + constructor(requestManager, options) { + this.requests = requestManager; + this.options = options; + } + /** + * Makes a request with the options provided. + */ + async make() { + const options = this.buildOptions(); + const res = await fetch(options.url, { + ...options + }); + if (!res.ok) { + const error = await res.json(); + throw new HypixelAPIError(error?.cause ?? res.statusText, res.status); + } + return res; + } + /** + * Creates an object containing the options to be passed to the request + */ + buildOptions() { + const apiKey = this.requests.client.options?.apiKey; + const headers = { + "Content-Type": "application/json" + }; + if (this.options.sendAPIKey) { + if (!apiKey) + throw new HypixelTSError("CLIENT_OPTIONS_MISSING", "apiKey"); + headers["API-Key"] = apiKey; + } + const options = { + url: `${this.requests.baseApiUrl}${this.options.path}`, + method: this.options.method ?? "GET", + headers + }; + return options; + } +}; +export { + ApiRequest +}; +//# sourceMappingURL=ApiRequest.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/rest/ApiRequest.mjs.map b/dist/esm/lib/rest/ApiRequest.mjs.map new file mode 100644 index 0000000..84cb854 --- /dev/null +++ b/dist/esm/lib/rest/ApiRequest.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/rest/ApiRequest.ts"],"sourcesContent":["import { RequestManager, HypixelAPIError, type HypixelAPIErrorResponse } from './index';\r\nimport { HypixelTSError } from '../errors/index';\r\n\r\n/**\r\n * The options supplied to the request\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface ApiRequestOptions {\r\n\t/**\r\n\t * The request path/endpoint\r\n\t */\r\n\tpath: string;\r\n\r\n\t/**\r\n\t * The request method, only `GET` is supported\r\n\t */\r\n\tmethod?: 'GET';\r\n\r\n\t/**\r\n\t * Whether to send the API key for this request\r\n\t */\r\n\tsendAPIKey?: boolean;\r\n}\r\n\r\n/**\r\n * Handles (sending/building options) requests\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class ApiRequest {\r\n\t/**\r\n\t * The request manager instance\r\n\t */\r\n\tpublic requests: RequestManager;\r\n\r\n\t/**\r\n\t * The options of this request\r\n\t */\r\n\tpublic options: ApiRequestOptions;\r\n\r\n\tpublic constructor(requestManager: RequestManager, options: ApiRequestOptions) {\r\n\t\tthis.requests = requestManager;\r\n\t\tthis.options = options;\r\n\t}\r\n\r\n\t/**\r\n\t * Makes a request with the options provided.\r\n\t */\r\n\tpublic async make() {\r\n\t\tconst options = this.buildOptions();\r\n\r\n\t\tconst res = await fetch(options.url, {\r\n\t\t\t...options\r\n\t\t});\r\n\r\n\t\tif (!res.ok) {\r\n\t\t\tconst error = (await res.json()) as HypixelAPIErrorResponse;\r\n\t\t\tthrow new HypixelAPIError(error?.cause ?? res.statusText, res.status);\r\n\t\t}\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an object containing the options to be passed to the request\r\n\t */\r\n\tpublic buildOptions() {\r\n\t\tconst apiKey = this.requests.client.options?.apiKey;\r\n\r\n\t\tconst headers: Record = {\r\n\t\t\t'Content-Type': 'application/json'\r\n\t\t};\r\n\r\n\t\tif (this.options.sendAPIKey) {\r\n\t\t\tif (!apiKey) throw new HypixelTSError('CLIENT_OPTIONS_MISSING', 'apiKey');\r\n\t\t\theaders['API-Key'] = apiKey;\r\n\t\t}\r\n\r\n\t\tconst options = {\r\n\t\t\turl: `${this.requests.baseApiUrl}${this.options.path}`,\r\n\t\t\tmethod: this.options.method ?? 'GET',\r\n\t\t\theaders\r\n\t\t};\r\n\r\n\t\treturn options;\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAyB,uBAAqD;AAC9E,SAAS,sBAAsB;AA6BxB,IAAM,aAAN,MAAiB;AAAA,EA9BxB,OA8BwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIhB;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEA,YAAY,gBAAgC,SAA4B;AAC9E,SAAK,WAAW;AAChB,SAAK,UAAU;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,OAAO;AACnB,UAAM,UAAU,KAAK,aAAa;AAElC,UAAM,MAAM,MAAM,MAAM,QAAQ,KAAK;AAAA,MACpC,GAAG;AAAA,IACJ,CAAC;AAED,QAAI,CAAC,IAAI,IAAI;AACZ,YAAM,QAAS,MAAM,IAAI,KAAK;AAC9B,YAAM,IAAI,gBAAgB,OAAO,SAAS,IAAI,YAAY,IAAI,MAAM;AAAA,IACrE;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,eAAe;AACrB,UAAM,SAAS,KAAK,SAAS,OAAO,SAAS;AAE7C,UAAM,UAAkC;AAAA,MACvC,gBAAgB;AAAA,IACjB;AAEA,QAAI,KAAK,QAAQ,YAAY;AAC5B,UAAI,CAAC;AAAQ,cAAM,IAAI,eAAe,0BAA0B,QAAQ;AACxE,cAAQ,SAAS,IAAI;AAAA,IACtB;AAEA,UAAM,UAAU;AAAA,MACf,KAAK,GAAG,KAAK,SAAS,UAAU,GAAG,KAAK,QAAQ,IAAI;AAAA,MACpD,QAAQ,KAAK,QAAQ,UAAU;AAAA,MAC/B;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/rest/HypixelAPIError.d.mts b/dist/esm/lib/rest/HypixelAPIError.d.mts new file mode 100644 index 0000000..fc0be38 --- /dev/null +++ b/dist/esm/lib/rest/HypixelAPIError.d.mts @@ -0,0 +1,26 @@ +/** + * Response body when an error is returned by the hypixel api + * @category Rest + * @group Rest + */ +interface HypixelAPIErrorResponse { + /** + * Whether or not the request is successful + */ + success: boolean; + /** + * The message explaining the error + */ + cause: string; +} +/** + * Error thrown when an error is encountered while querying the hypixel API + * @category Rest + * @group Rest + */ +declare class HypixelAPIError extends Error { + code: number; + constructor(message: string, code: number); +} + +export { HypixelAPIError, type HypixelAPIErrorResponse }; diff --git a/dist/esm/lib/rest/HypixelAPIError.mjs b/dist/esm/lib/rest/HypixelAPIError.mjs new file mode 100644 index 0000000..430b87b --- /dev/null +++ b/dist/esm/lib/rest/HypixelAPIError.mjs @@ -0,0 +1,19 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/rest/HypixelAPIError.ts +var HypixelAPIError = class extends Error { + static { + __name(this, "HypixelAPIError"); + } + code; + constructor(message, code) { + super(message); + this.message = message; + this.code = code; + } +}; +export { + HypixelAPIError +}; +//# sourceMappingURL=HypixelAPIError.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/rest/HypixelAPIError.mjs.map b/dist/esm/lib/rest/HypixelAPIError.mjs.map new file mode 100644 index 0000000..019d196 --- /dev/null +++ b/dist/esm/lib/rest/HypixelAPIError.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/rest/HypixelAPIError.ts"],"sourcesContent":["/**\r\n * Response body when an error is returned by the hypixel api\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport interface HypixelAPIErrorResponse {\r\n\t/**\r\n\t * Whether or not the request is successful\r\n\t */\r\n\tsuccess: boolean;\r\n\r\n\t/**\r\n\t * The message explaining the error\r\n\t */\r\n\tcause: string;\r\n}\r\n\r\n/**\r\n * Error thrown when an error is encountered while querying the hypixel API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class HypixelAPIError extends Error {\r\n\tpublic code: number;\r\n\r\n\tpublic constructor(message: string, code: number) {\r\n\t\tsuper(message);\r\n\t\tthis.message = message;\r\n\t\tthis.code = code;\r\n\t}\r\n}\r\n"],"mappings":";;;;AAsBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAtB3C,OAsB2C;AAAA;AAAA;AAAA,EACnC;AAAA,EAEA,YAAY,SAAiB,MAAc;AACjD,UAAM,OAAO;AACb,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACb;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/rest/RequestManager.d.mts b/dist/esm/lib/rest/RequestManager.d.mts new file mode 100644 index 0000000..919c4d6 --- /dev/null +++ b/dist/esm/lib/rest/RequestManager.d.mts @@ -0,0 +1,2 @@ +export { RequestManager } from '../../index.mjs'; +import './HypixelAPIError.mjs'; diff --git a/dist/esm/lib/rest/RequestManager.mjs b/dist/esm/lib/rest/RequestManager.mjs new file mode 100644 index 0000000..d00281e --- /dev/null +++ b/dist/esm/lib/rest/RequestManager.mjs @@ -0,0 +1,47 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/lib/rest/RequestManager.ts +import { AsyncQueue } from "@sapphire/async-queue"; +import { ApiRequest } from "./ApiRequest.mjs"; +var RequestManager = class { + static { + __name(this, "RequestManager"); + } + /** + * The hypixel.ts client instance + */ + client; + /** + * The base url of the hypixel API + */ + baseApiUrl; + /** + * Queue for requests + * @see {@link https://npmjs.com/@sapphire/async-queue} + */ + queue; + constructor(client) { + this.client = client; + this.baseApiUrl = client.options?.baseApiUrl ?? "https://api.hypixel.net"; + this.queue = new AsyncQueue(); + } + /** + * Makes the api request and pushes it to the request queue + * @param path The path/endpoint to make the request to + * @param sendAPIKey Whether or not to send the apiKey with this request + */ + async execute(path, sendAPIKey) { + await this.queue.wait(); + try { + const request = await new ApiRequest(this, { path, sendAPIKey }).make(); + return request.json(); + } finally { + this.queue.shift(); + } + } +}; +export { + RequestManager +}; +//# sourceMappingURL=RequestManager.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/rest/RequestManager.mjs.map b/dist/esm/lib/rest/RequestManager.mjs.map new file mode 100644 index 0000000..7faea7e --- /dev/null +++ b/dist/esm/lib/rest/RequestManager.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/rest/RequestManager.ts"],"sourcesContent":["import { AsyncQueue } from '@sapphire/async-queue';\r\nimport { ApiRequest } from './ApiRequest';\r\nimport { Client } from '../Client';\r\n\r\n/**\r\n * Manages the requests to the API\r\n * @category Rest\r\n * @group Rest\r\n */\r\nexport class RequestManager {\r\n\t/**\r\n\t * The hypixel.ts client instance\r\n\t */\r\n\tpublic client: Client;\r\n\r\n\t/**\r\n\t * The base url of the hypixel API\r\n\t */\r\n\tpublic baseApiUrl: string;\r\n\r\n\t/**\r\n\t * Queue for requests\r\n\t * @see {@link https://npmjs.com/@sapphire/async-queue}\r\n\t */\r\n\tprivate queue: AsyncQueue;\r\n\r\n\tpublic constructor(client: Client) {\r\n\t\tthis.client = client;\r\n\t\tthis.baseApiUrl = client.options?.baseApiUrl ?? 'https://api.hypixel.net';\r\n\t\tthis.queue = new AsyncQueue();\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the api request and pushes it to the request queue\r\n\t * @param path The path/endpoint to make the request to\r\n\t * @param sendAPIKey Whether or not to send the apiKey with this request\r\n\t */\r\n\tpublic async execute(path: string, sendAPIKey: boolean) {\r\n\t\tawait this.queue.wait();\r\n\t\ttry {\r\n\t\t\tconst request = await new ApiRequest(this, { path, sendAPIKey }).make();\r\n\t\t\treturn request.json() as T;\r\n\t\t} finally {\r\n\t\t\tthis.queue.shift();\r\n\t\t}\r\n\t}\r\n}\r\n"],"mappings":";;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAQpB,IAAM,iBAAN,MAAqB;AAAA,EAT5B,OAS4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIpB;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC;AAAA,EAED,YAAY,QAAgB;AAClC,SAAK,SAAS;AACd,SAAK,aAAa,OAAO,SAAS,cAAc;AAChD,SAAK,QAAQ,IAAI,WAAW;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,QAAW,MAAc,YAAqB;AAC1D,UAAM,KAAK,MAAM,KAAK;AACtB,QAAI;AACH,YAAM,UAAU,MAAM,IAAI,WAAW,MAAM,EAAE,MAAM,WAAW,CAAC,EAAE,KAAK;AACtE,aAAO,QAAQ,KAAK;AAAA,IACrB,UAAE;AACD,WAAK,MAAM,MAAM;AAAA,IAClB;AAAA,EACD;AACD;","names":[]} \ No newline at end of file diff --git a/dist/esm/lib/rest/index.d.mts b/dist/esm/lib/rest/index.d.mts new file mode 100644 index 0000000..2f92709 --- /dev/null +++ b/dist/esm/lib/rest/index.d.mts @@ -0,0 +1,2 @@ +export { ApiRequest, ApiRequestOptions, RequestManager } from '../../index.mjs'; +export { HypixelAPIError, HypixelAPIErrorResponse } from './HypixelAPIError.mjs'; diff --git a/dist/esm/lib/rest/index.mjs b/dist/esm/lib/rest/index.mjs new file mode 100644 index 0000000..66f3965 --- /dev/null +++ b/dist/esm/lib/rest/index.mjs @@ -0,0 +1,5 @@ +// src/lib/rest/index.ts +export * from "./ApiRequest.mjs"; +export * from "./HypixelAPIError.mjs"; +export * from "./RequestManager.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/dist/esm/lib/rest/index.mjs.map b/dist/esm/lib/rest/index.mjs.map new file mode 100644 index 0000000..26263d4 --- /dev/null +++ b/dist/esm/lib/rest/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/lib/rest/index.ts"],"sourcesContent":["export * from './ApiRequest';\r\nexport * from './HypixelAPIError';\r\nexport * from './RequestManager';\r\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]} \ No newline at end of file diff --git a/package.json b/package.json index 6eae7c4..b80389d 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { - "name": "hypixel.ts", - "version": "2.0.0", + "name": "fixed.hypixel.ts", + "version": "2.0.2", "description": "A simple, easy to use wrapper for Hypixel API.", - "homepage": "https://hypixel.js.org/", + "homepage": "https://github.com/EnchStudio/hypixel.ts/", "main": "dist/cjs/index.js", "module": "dist/esm/index.mjs", "types": "dist/cjs/index.d.ts", - "author": "FC5570", + "author": "EnchStudio", "license": "MIT", "exports": { "require": { @@ -57,10 +57,10 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/FC5570/hypixel.ts.git" + "url": "git+https://github.com/EnchStudio/hypixel.ts.git" }, "bugs": { - "url": "https://github.com/FC5570/hypixel.ts/issues" + "url": "https://github.com/EnchStudio/hypixel.ts/issues" }, "keywords": [ "hypixel", diff --git a/src/lib/classes/SkyBlockMuseum.ts b/src/lib/classes/SkyBlockMuseum.ts new file mode 100644 index 0000000..f290e56 --- /dev/null +++ b/src/lib/classes/SkyBlockMuseum.ts @@ -0,0 +1,20 @@ +import { Base } from './Base'; +import type { Client } from '../Client'; +import type { APISkyBlockMuseum } from '../typings'; + +export interface SkyBlockMuseum extends APISkyBlockMuseum {} +/** + * The SkyBlockMuseum class. + * @category Classes + * @Group Classes + */ +export class SkyBlockMuseum extends Base { + /** + * @param client Instantiated (and started) hypixel.ts client + * @param data SkyBlock profile data received from API + */ + public constructor(client: Client, data: APISkyBlockMuseum) { + super(client); + Object.assign(this, data); + } +} diff --git a/src/lib/classes/index.ts b/src/lib/classes/index.ts index cac06e7..f2899d1 100644 --- a/src/lib/classes/index.ts +++ b/src/lib/classes/index.ts @@ -4,4 +4,5 @@ export * from './Guild'; export * from './Player'; export * from './SkyBlockAuction'; export * from './SkyBlockProfile'; +export * from './SkyBlockMuseum'; export * from './Util'; diff --git a/src/lib/managers/SkyBlockManager.ts b/src/lib/managers/SkyBlockManager.ts index b958ad1..9d72d0b 100644 --- a/src/lib/managers/SkyBlockManager.ts +++ b/src/lib/managers/SkyBlockManager.ts @@ -1,22 +1,23 @@ import { BaseManager } from './BaseManager'; import { HypixelTSError } from '../errors/index'; -import { SkyBlockProfile, SkyBlockAuction } from '../classes/index'; +import { SkyBlockProfile, SkyBlockAuction, SkyBlockMuseum } from '../classes/index'; import type { Client } from '../Client'; -import type { - APISkyBlockProfile, - FetchCollectionsResponse, - FetchSkillsResponse, - FetchItemsResponse, - FetchElectionAndMayorResponse, - FetchActiveBingoGoalsResponse, - FetchNewsResponse, - APISkyBlockAuction, - FetchActiveAuctionsResponse, - FetchBazaarResponse, - RecentlyEndedAuctionsResponse, - FetchBingoDataResponse, - FetchFireSalesResponse, - FetchFireSalesResponseFireSale +import { + type APISkyBlockProfile, + type FetchCollectionsResponse, + type FetchSkillsResponse, + type FetchItemsResponse, + type FetchElectionAndMayorResponse, + type FetchActiveBingoGoalsResponse, + type FetchNewsResponse, + type APISkyBlockAuction, + type FetchActiveAuctionsResponse, + type FetchBazaarResponse, + type RecentlyEndedAuctionsResponse, + type FetchBingoDataResponse, + type FetchFireSalesResponse, + type FetchFireSalesResponseFireSale, + APISkyBlockMuseum } from '../typings'; /** @@ -140,7 +141,7 @@ export class SkyBlockManager extends BaseManager { if (page && typeof page !== 'number') throw new HypixelTSError('METHOD_INVALID_OPTIONS', 'SkyBlockManager', 'fetchActiveAuctions', 'page', ['number']); - const data = await this.makeGetRequest('/skyblock/auctions'); + const data = await this.makeGetRequest(`/skyblock/auctions${page ? '?page=' + page : ''}`); if (resolveAuctions) { const parsed = []; @@ -201,6 +202,18 @@ export class SkyBlockManager extends BaseManager { return new SkyBlockProfile(this.client, data); } + /** + * Fetch a Skyblock profile museum (using a SkyBlock profile uuid). The data returned can differ depending on the players in-game API settings. + * @param profileUuid The uuid of the SkyBlock profile + */ + public async fetchMuseum(profileUuid: string): Promise { + if (!profileUuid) throw new HypixelTSError('METHOD_MISSING_OPTION', 'SkyBlockManager', 'fetchMuseum', 'profileUuid'); + + const data = await this.makeGetRequest(`/skyblock/museum?profile=${profileUuid}`); + + return new SkyBlockMuseum(this.client, data); + } + /** * Fetch a SkyBlock profiles of a player * @param playerUuid The uuid of the player diff --git a/src/lib/typings/classes/APISkyBlockAuction.d.ts b/src/lib/typings/classes/APISkyBlockAuction.d.ts index 93df489..d45a03a 100644 --- a/src/lib/typings/classes/APISkyBlockAuction.d.ts +++ b/src/lib/typings/classes/APISkyBlockAuction.d.ts @@ -17,6 +17,7 @@ export interface APISkyBlockAuction { category: string; tier: string; starting_bid: number; + bin: boolean; item_bytes: { type: number; data: string }; claimed: boolean; claimed_bidders: unknown[]; diff --git a/src/lib/typings/classes/APISkyBlockMuseum.d.ts b/src/lib/typings/classes/APISkyBlockMuseum.d.ts new file mode 100644 index 0000000..273b61b --- /dev/null +++ b/src/lib/typings/classes/APISkyBlockMuseum.d.ts @@ -0,0 +1,35 @@ +/** + * The Museum object returned from the API (in JSON) which is converted to the @see {@link SkyBlockMuseum} class. + * @category Interfaces + */ + +export interface APISkyBlockMuseum { + [key: string]: APISkyBlockMuseumMember +} + +export interface APISkyBlockMuseumMember { + value: number + appraisal: boolean + items: APISkyBlockMuseumItemObject + special: APISkyBlockMuseumItem[] +} + +export interface APISkyBlockMuseumItemObject { + [key: string]: APISkyBlockMuseumItem +} + +/** + * @category Interfaces + */ +export interface APISkyBlockMuseumItem { + donated_time: number + items: APISkyBlockMuseumItemItem +} + +/** + * @category Interfaces + */ +export interface APISkyBlockMuseumItemItem { + type: number + data: string +} \ No newline at end of file diff --git a/src/lib/typings/classes/index.ts b/src/lib/typings/classes/index.ts index 88399de..d7505e5 100644 --- a/src/lib/typings/classes/index.ts +++ b/src/lib/typings/classes/index.ts @@ -2,4 +2,5 @@ export * from './APIGuild.d'; export * from './APIPlayer.d'; export * from './APISkyBlockAuction.d'; export * from './APISkyBlockProfile.d'; +export * from './APISkyBlockMuseum.d'; export * from './Util.d'; diff --git a/src/lib/typings/managers/SkyBlockManager.d.ts b/src/lib/typings/managers/SkyBlockManager.d.ts index b4863ea..8a89338 100644 --- a/src/lib/typings/managers/SkyBlockManager.d.ts +++ b/src/lib/typings/managers/SkyBlockManager.d.ts @@ -67,7 +67,7 @@ export interface FetchItemsResponseItem { */ export interface FetchElectionAndMayorResponse extends BaseResourceResponse { mayor: FetchElectionAndMayorResponseMayor; - current: FetchElectionAndMayorResponseCurrent; + current?: FetchElectionAndMayorResponseCurrent; } /** @@ -78,7 +78,7 @@ export interface FetchElectionAndMayorResponseMayor { name: string; perks: FetchElectionAndMayorResponseMayorPerks[]; election: FetchElectionAndMayorResponseElection; - current: FetchElectionAndMayorResponseCurrent; + current?: FetchElectionAndMayorResponseCurrent; } /** diff --git a/src/tests/managers/SkyBlockManager.test.ts b/src/tests/managers/SkyBlockManager.test.ts index 3308161..9ca6caa 100644 --- a/src/tests/managers/SkyBlockManager.test.ts +++ b/src/tests/managers/SkyBlockManager.test.ts @@ -17,10 +17,15 @@ test('SkyBlockManager.fetchItems returns items', async ({ client }) => { expect(items).toBeTypeOf('object'); }); +// test('SkyBlockManager.fetchElectionAndMayor returns election and mayor', async ({ client }) => { +// const { mayor, current } = await client.skyblock.fetchElectionAndMayor(); +// expect(mayor).toBeTypeOf('object'); +// expect(current).toBeTypeOf('object'); +// }); + test('SkyBlockManager.fetchElectionAndMayor returns election and mayor', async ({ client }) => { - const { mayor, current } = await client.skyblock.fetchElectionAndMayor(); + const { mayor } = await client.skyblock.fetchElectionAndMayor(); expect(mayor).toBeTypeOf('object'); - expect(current).toBeTypeOf('object'); }); test('SkyBlockManager.fetchActiveBingoGoals returns bingo goals', async ({ client }) => { @@ -53,6 +58,11 @@ test('SkyBlockManager.fetchProfile returns profile', async ({ client }) => { expect(product).toBeInstanceOf(SkyBlockProfile); }); +test('SkyBlockManager.fetchMuseum returns SkyBlockMuseum[]', async ({ client }) => { + const members = await client.skyblock.fetchMuseum('644ef38b50794423995df9fdca3d121c'); + expect(members).toBeTypeOf('object') +}) + test('SkyBlockManager.fetchPlayerSkyBlockProfiles returns player profiles', async ({ client }) => { const members = await client.skyblock.fetchPlayerSkyBlockProfiles('d62e8944ca274bcb8b0e43959446d659'); expect(members).toBeTypeOf('object'); diff --git a/yarn.lock b/yarn.lock index 863be9d..2afe08f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2497,6 +2497,36 @@ __metadata: languageName: node linkType: hard +"fixed.hypixel.ts@workspace:.": + version: 0.0.0-use.local + resolution: "fixed.hypixel.ts@workspace:." + dependencies: + "@commitlint/cli": "npm:^19.3.0" + "@commitlint/config-conventional": "npm:^19.2.2" + "@favware/cliff-jumper": "npm:^3.0.3" + "@sapphire/async-queue": "npm:^1.5.2" + "@sapphire/eslint-config": "npm:^5.0.4" + "@sapphire/prettier-config": "npm:^2.0.0" + "@sapphire/ts-config": "npm:^5.0.1" + "@types/node": "npm:^20.12.7" + "@typescript-eslint/eslint-plugin": "npm:^7.7.1" + "@typescript-eslint/parser": "npm:^7.7.1" + "@vitest/coverage-c8": "npm:^0.33.0" + "@vitest/coverage-v8": "npm:^1.5.0" + esbuild-plugin-file-path-extensions: "npm:^2.0.0" + eslint: "npm:^8.57.0" + eslint-plugin-prettier: "npm:^5.1.3" + git-cliff: "npm:^2.2.1" + husky: "npm:^9.0.11" + lint-staged: "npm:^15.2.2" + prettier: "npm:^3.2.5" + tsup: "npm:^8.0.2" + typedoc: "npm:^0.25.13" + typescript: "npm:^5.4.5" + vitest: "npm:^1.5.0" + languageName: unknown + linkType: soft + "flat-cache@npm:^3.0.4": version: 3.2.0 resolution: "flat-cache@npm:3.2.0" @@ -2875,36 +2905,6 @@ __metadata: languageName: node linkType: hard -"hypixel.ts@workspace:.": - version: 0.0.0-use.local - resolution: "hypixel.ts@workspace:." - dependencies: - "@commitlint/cli": "npm:^19.3.0" - "@commitlint/config-conventional": "npm:^19.2.2" - "@favware/cliff-jumper": "npm:^3.0.3" - "@sapphire/async-queue": "npm:^1.5.2" - "@sapphire/eslint-config": "npm:^5.0.4" - "@sapphire/prettier-config": "npm:^2.0.0" - "@sapphire/ts-config": "npm:^5.0.1" - "@types/node": "npm:^20.12.7" - "@typescript-eslint/eslint-plugin": "npm:^7.7.1" - "@typescript-eslint/parser": "npm:^7.7.1" - "@vitest/coverage-c8": "npm:^0.33.0" - "@vitest/coverage-v8": "npm:^1.5.0" - esbuild-plugin-file-path-extensions: "npm:^2.0.0" - eslint: "npm:^8.57.0" - eslint-plugin-prettier: "npm:^5.1.3" - git-cliff: "npm:^2.2.1" - husky: "npm:^9.0.11" - lint-staged: "npm:^15.2.2" - prettier: "npm:^3.2.5" - tsup: "npm:^8.0.2" - typedoc: "npm:^0.25.13" - typescript: "npm:^5.4.5" - vitest: "npm:^1.5.0" - languageName: unknown - linkType: soft - "iconv-lite@npm:^0.6.2": version: 0.6.3 resolution: "iconv-lite@npm:0.6.3"