diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..88bf97c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = false \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..714920c --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "editorconfig.editorconfig", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "eamodio.gitlens", + "aaron-bond.better-comments" + ] +} \ No newline at end of file diff --git a/src/API/getAchievements.ts b/src/API/getAchievements.ts index 97fc6ec..3487ba3 100644 --- a/src/API/getAchievements.ts +++ b/src/API/getAchievements.ts @@ -9,7 +9,7 @@ export default class getAchievements extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/resources/achievements'); if (res.raw) return res; return new Achievements(res); diff --git a/src/API/getActiveHouses.ts b/src/API/getActiveHouses.ts index 3ded977..bd467b3 100644 --- a/src/API/getActiveHouses.ts +++ b/src/API/getActiveHouses.ts @@ -9,7 +9,7 @@ export default class getActiveHouses extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/housing/active'); if (res.raw) return res; return res.length ? res.map((b: any) => new House(b)) : []; diff --git a/src/API/getBoosters.ts b/src/API/getBoosters.ts index 61ad753..2d43f5a 100644 --- a/src/API/getBoosters.ts +++ b/src/API/getBoosters.ts @@ -9,7 +9,7 @@ export default class getBoosters extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/boosters'); if (res.raw) return res; return res.boosters.length ? res.boosters.map((b: any) => new Booster(b)).reverse() : []; diff --git a/src/API/getChallenges.ts b/src/API/getChallenges.ts index 60fe1ad..ca8c405 100644 --- a/src/API/getChallenges.ts +++ b/src/API/getChallenges.ts @@ -9,7 +9,7 @@ export default class getChallenges extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/resources/challenges'); if (res.raw) return res; return new Challenges(res); diff --git a/src/API/getGameCounts.ts b/src/API/getGameCounts.ts index db9250d..ac69205 100644 --- a/src/API/getGameCounts.ts +++ b/src/API/getGameCounts.ts @@ -9,7 +9,7 @@ export default class getGameCounts extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/counts'); if (res.raw) return res; return new GameCounts(res); diff --git a/src/API/getGuild.ts b/src/API/getGuild.ts index 4cbd474..15c5cec 100644 --- a/src/API/getGuild.ts +++ b/src/API/getGuild.ts @@ -12,7 +12,7 @@ export default class getGuild extends Endpoint { this.client = client; } - async execute(searchParameter: 'id' | 'name' | 'player', query: string) { + async execute(searchParameter: 'id' | 'name' | 'player', query: string): Promise { if (!query) throw new Error(Errors.NO_GUILD_QUERY); if ('id' === searchParameter && !isGuildID(query)) throw new Error(Errors.INVALID_GUILD_ID); const isPlayerQuery = 'player' === searchParameter; diff --git a/src/API/getGuildAchievements.ts b/src/API/getGuildAchievements.ts index 1abb178..5b4b40e 100644 --- a/src/API/getGuildAchievements.ts +++ b/src/API/getGuildAchievements.ts @@ -9,7 +9,7 @@ export default class getGuildAchievements extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/resources/guilds/achievements'); if (res.raw) return res; return new GuildAchievements(res); diff --git a/src/API/getHouse.ts b/src/API/getHouse.ts index 9e0dec4..1e7fabc 100644 --- a/src/API/getHouse.ts +++ b/src/API/getHouse.ts @@ -10,7 +10,7 @@ export default class getHouse extends Endpoint { this.client = client; } - async execute(query: string) { + async execute(query: string): Promise { if (!query) throw new Error(Errors.NO_UUID); const res = await this.client.requests.request(`/housing/house?house=${query}`); if (res.raw) return res; diff --git a/src/API/getLeaderboards.ts b/src/API/getLeaderboards.ts index 4a320cc..11f757c 100644 --- a/src/API/getLeaderboards.ts +++ b/src/API/getLeaderboards.ts @@ -11,7 +11,7 @@ export default class getLeaderboards extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/leaderboards'); if (res.raw) return res; if (!res.leaderboards) throw new Error(Errors.SOMETHING_WENT_WRONG.replace(/{cause}/, 'Try again.')); diff --git a/src/API/getPlayer.ts b/src/API/getPlayer.ts index e038634..2651af2 100644 --- a/src/API/getPlayer.ts +++ b/src/API/getPlayer.ts @@ -11,7 +11,7 @@ export default class getPlayer extends Endpoint { this.client = client; } - async execute(query: string) { + async execute(query: string): Promise { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); query = await toUuid(query); const res = await this.client.requests.request(`/player?uuid=${query}`); diff --git a/src/API/getPlayerHouses.ts b/src/API/getPlayerHouses.ts index e245c60..fa8cd27 100644 --- a/src/API/getPlayerHouses.ts +++ b/src/API/getPlayerHouses.ts @@ -11,7 +11,7 @@ export default class getPlayerHouses extends Endpoint { this.client = client; } - async execute(query: string): Promise { + async execute(query: string): Promise { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); query = await toUuid(query); const res = await this.client.requests.request(`/housing/houses?player=${query}`); diff --git a/src/API/getQuests.ts b/src/API/getQuests.ts index 70c476c..b3a09e1 100644 --- a/src/API/getQuests.ts +++ b/src/API/getQuests.ts @@ -9,7 +9,7 @@ export default class getQuests extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/resources/quests'); if (res.raw) return res; return new Quests(res); diff --git a/src/API/getRecentGames.ts b/src/API/getRecentGames.ts index 7ad3b71..6ea63eb 100644 --- a/src/API/getRecentGames.ts +++ b/src/API/getRecentGames.ts @@ -11,7 +11,7 @@ export default class getRecentGames extends Endpoint { this.client = client; } - async execute(query: string) { + async execute(query: string): Promise { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); query = await toUuid(query); const res = await this.client.requests.request(`/recentgames?uuid=${query}`); diff --git a/src/API/getSkyblockAuction.ts b/src/API/getSkyblockAuction.ts index b6d01da..e7c9a73 100644 --- a/src/API/getSkyblockAuction.ts +++ b/src/API/getSkyblockAuction.ts @@ -11,7 +11,11 @@ export default class getSkyblockAction extends Endpoint { this.client = client; } - async execute(query: string, type: 'PROFILE' | 'PLAYER' | 'AUCTION', includeItemBytes: boolean = false) { + async execute( + query: string, + type: 'PROFILE' | 'PLAYER' | 'AUCTION', + includeItemBytes: boolean = false + ): Promise { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); let filter; if ('PROFILE' === type) { diff --git a/src/API/getSkyblockAuctionsByPlayer.ts b/src/API/getSkyblockAuctionsByPlayer.ts index 82d797c..7939cf6 100644 --- a/src/API/getSkyblockAuctionsByPlayer.ts +++ b/src/API/getSkyblockAuctionsByPlayer.ts @@ -11,7 +11,7 @@ export default class getSkyblockActionsByPlayer extends Endpoint { this.client = client; } - async execute(query: string, includeItemBytes: boolean) { + async execute(query: string, includeItemBytes: boolean): Promise { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); query = await toUuid(query); const res = await this.client.requests.request(`/skyblock/auction?player=${query}`); diff --git a/src/API/getSkyblockBazaar.ts b/src/API/getSkyblockBazaar.ts index 28e6b52..b360560 100644 --- a/src/API/getSkyblockBazaar.ts +++ b/src/API/getSkyblockBazaar.ts @@ -9,7 +9,7 @@ export default class getSkyblockBazaar extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/skyblock/bazaar'); if (res.raw) return res; const productsKeys = Object.keys(res.products); diff --git a/src/API/getSkyblockBingo.ts b/src/API/getSkyblockBingo.ts index 4e17f77..b52a589 100644 --- a/src/API/getSkyblockBingo.ts +++ b/src/API/getSkyblockBingo.ts @@ -9,7 +9,7 @@ export default class getSkyblockBingo extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/resources/skyblock/bingo'); if (res.raw) return res; return new BingoData(res); diff --git a/src/API/getSkyblockBingoByPlayer.ts b/src/API/getSkyblockBingoByPlayer.ts index 03c071f..421d443 100644 --- a/src/API/getSkyblockBingoByPlayer.ts +++ b/src/API/getSkyblockBingoByPlayer.ts @@ -11,7 +11,7 @@ export default class getBingoByPlayer extends Endpoint { this.client = client; } - async execute(query: string) { + async execute(query: string): Promise { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); query = await toUuid(query); const res = await this.client.requests.request(`/skyblock/uuid?player=${query}`); diff --git a/src/API/getSkyblockEndedAuctions.ts b/src/API/getSkyblockEndedAuctions.ts index e5b5951..2916113 100644 --- a/src/API/getSkyblockEndedAuctions.ts +++ b/src/API/getSkyblockEndedAuctions.ts @@ -10,7 +10,7 @@ export default class getSkyblockEndedAuctions extends Endpoint { this.client = client; } - async execute(includeItemBytes: any): Promise { + async execute(includeItemBytes: any): Promise<{ info: AuctionInfo; auctions: PartialAuction[] }> { const res = await this.client.requests.request('/skyblock/auctions_ended'); if (res.raw) return res; return { diff --git a/src/API/getSkyblockFireSales.ts b/src/API/getSkyblockFireSales.ts index 43ed427..d1fe015 100644 --- a/src/API/getSkyblockFireSales.ts +++ b/src/API/getSkyblockFireSales.ts @@ -9,7 +9,7 @@ export default class getSkyblockFireSales extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/skyblock/firesales'); if (res.raw) return res; return res.sales.length ? res.sales.map((a: any) => new FireSale(a)) : []; diff --git a/src/API/getSkyblockGarden.ts b/src/API/getSkyblockGarden.ts index 40c3022..19debbd 100644 --- a/src/API/getSkyblockGarden.ts +++ b/src/API/getSkyblockGarden.ts @@ -9,7 +9,7 @@ export default class getSkyblockGarden extends Endpoint { this.client = client; } - async execute(profileId: string) { + async execute(profileId: string): Promise { const res = await this.client.requests.request(`/skyblock/garden?profile=${profileId}`); if (res.raw) return res; return new SkyblockGarden(res); diff --git a/src/API/getSkyblockGovernment.ts b/src/API/getSkyblockGovernment.ts index ebd6fc3..2bd2443 100644 --- a/src/API/getSkyblockGovernment.ts +++ b/src/API/getSkyblockGovernment.ts @@ -9,7 +9,7 @@ export default class getSkyblockGovernment extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/resources/skyblock/election'); if (res.raw) return res; return new GovernmentData(res); diff --git a/src/API/getSkyblockMember.ts b/src/API/getSkyblockMember.ts index c39f826..efa813b 100644 --- a/src/API/getSkyblockMember.ts +++ b/src/API/getSkyblockMember.ts @@ -11,7 +11,7 @@ export default class getSkyblockMember extends Endpoint { this.client = client; } - async execute(query: string) { + async execute(query: string): Promise> { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); query = await toUuid(query); const res = await this.client.requests.request(`/skyblock/profiles?uuid=${query}`); diff --git a/src/API/getSkyblockMuseum.ts b/src/API/getSkyblockMuseum.ts index 0f6889c..b263352 100644 --- a/src/API/getSkyblockMuseum.ts +++ b/src/API/getSkyblockMuseum.ts @@ -11,7 +11,7 @@ export default class getSkyblockMuseum extends Endpoint { this.client = client; } - async execute(query: string, profileId: string) { + async execute(query: string, profileId: string): Promise { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); query = await toUuid(query); const res = await this.client.requests.request(`/skyblock/museum?uuid=${query}&profile=${profileId}`); diff --git a/src/API/getSkyblockNews.ts b/src/API/getSkyblockNews.ts index 4b56b3f..2692ae7 100644 --- a/src/API/getSkyblockNews.ts +++ b/src/API/getSkyblockNews.ts @@ -9,7 +9,7 @@ export default class getSkyblockNews extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/skyblock/news'); if (res.raw) return res; return res.items.map((i: any) => new SkyblockNews(i)); diff --git a/src/API/getSkyblockProfiles.ts b/src/API/getSkyblockProfiles.ts index 7742700..d524ff1 100644 --- a/src/API/getSkyblockProfiles.ts +++ b/src/API/getSkyblockProfiles.ts @@ -10,7 +10,7 @@ export default class getSkyblockProfiles extends Endpoint { this.client = client; } - async execute(query: string) { + async execute(query: string): Promise { if (!query) throw new Error(Errors.NO_NICKNAME_UUID); query = await toUuid(query); const res = await this.client.requests.request(`/skyblock/profiles?uuid=${query}`); diff --git a/src/API/getWatchdogStats.ts b/src/API/getWatchdogStats.ts index 780d744..2e42c80 100644 --- a/src/API/getWatchdogStats.ts +++ b/src/API/getWatchdogStats.ts @@ -9,7 +9,7 @@ export default class getWatchdogStatsEndpoint extends Endpoint { this.client = client; } - async execute() { + async execute(): Promise { const res = await this.client.requests.request('/punishmentstats'); if (res.raw) return res; return new WatchdogStats(res); diff --git a/src/Client.ts b/src/Client.ts index 0f4acb5..55ef4a2 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -20,7 +20,6 @@ class Client { declare rateLimit?: 'AUTO' | 'HARD' | 'NONE'; declare silent: boolean; declare checkForUpdates: boolean; - declare endpoints: any; constructor(key: string, options?: ClientOptions) { this.key = key; @@ -37,7 +36,11 @@ class Client { this.cacheHandler = new CacheHandler(this); for (const func in API) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error const endpoint = new API[func](this); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error this[func] = endpoint.execute.bind(endpoint); }