Skip to content

Commit 0709dfe

Browse files
skin sort
1 parent e8bb1c1 commit 0709dfe

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mcutils-js-api",
3-
"version": "2.0.57",
3+
"version": "2.0.58",
44
"module": "dist/index.js",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { CachedPlayerName } from "./types/cache/cached-player-name";
22
import { Page } from "./types/pagination/pagination";
33
import { Cape } from "./types/player/cape/cape";
44
import type { BasicPlayer, FullPlayer, PlayerType } from "./types/player/player";
5-
import { Skin } from "./types/player/skin/skin";
65
import type { RecentUsernameChange } from "./types/player/recent-username-change";
6+
import { Skin } from "./types/player/skin/skin";
7+
import { SkinLookupSort } from "./types/player/skin/skin-lookup-sort";
78
import type { ErrorResponse } from "./types/response/error-response";
89
import type { IpLookup } from "./types/response/ip-lookup-response";
910
import type { ServerBlockedResponse } from "./types/response/server-blocked-response";
@@ -288,8 +289,10 @@ export class McUtilsAPI {
288289
* @param page the page to fetch (default: 1)
289290
* @returns the list of skins or the error (if one occurred)
290291
*/
291-
async fetchSkins(page: number = 1): Promise<{ skins?: Page<Skin>; error?: ErrorResponse }> {
292-
const { data, error } = await this.request<Page<Skin>>(`/skins${this.buildParams({ page: String(page) })}`);
292+
async fetchSkins(page: number = 1, type?: SkinLookupSort): Promise<{ skins?: Page<Skin>; error?: ErrorResponse }> {
293+
const { data, error } = await this.request<Page<Skin>>(
294+
`/skins${this.buildParams({ page: String(page), sort: type ?? "trending" })}`,
295+
);
293296
return error ? { error } : { skins: data };
294297
}
295298

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type SkinLookupSort = "trending" | "latest" | "top";

0 commit comments

Comments
 (0)