diff --git a/src/OAPI.ts b/src/OAPI.ts index f72c177..6d9c9b1 100644 --- a/src/OAPI.ts +++ b/src/OAPI.ts @@ -4,7 +4,8 @@ import type { RawServerInfoV2, RawServerInfoV3, RawQuarterResponseV3, RawEntityV3, DiscordReqObject, DiscordResObject, - RawLocationResponseV3 + RawLocationResponseV3, + RawPlayerV3 } from './types/index.js' import { townyData } from './utils/endpoint.js' @@ -102,7 +103,7 @@ export class OAPIV3 { static quarters = (...ids: string[]): Promise => townyData('/quarters', 'v3', { query: ids }) static quarterList = (): Promise => townyData('/quarters', 'v3') - static players = (...ids: string[]): Promise => townyData('/players', 'v3', { query: ids }) + static players = (...ids: string[]): Promise => townyData('/players', 'v3', { query: ids }) static playerList = (): Promise => townyData('/players', 'v3') } diff --git a/src/types/oapi.ts b/src/types/oapi.ts index 7234a16..0790da0 100644 --- a/src/types/oapi.ts +++ b/src/types/oapi.ts @@ -273,4 +273,47 @@ export interface RawLocationResponseV3 { town?: RawEntityV3 nation?: RawEntityV3 } + +export interface RawPlayerV3 extends RawEntityV3 { + title?: string + surname?: string + formattedName: string + about: string + town?: RawEntityV3 + nation?: RawEntityV3 + timestamps: { + registered: number + joinedTownAt?: number + lastOnline?: number + } + status: { + isOnline: boolean, + isNPC: boolean + isMayor: boolean + isKing: boolean + hasTown: boolean + hasNation: boolean + } + stats: { + balance: number + numFriends: number + } + perms: { + build: [boolean, boolean, boolean, boolean] + destroy: [boolean, boolean, boolean, boolean] + switch: [boolean, boolean, boolean, boolean] + itemUse: [boolean, boolean, boolean, boolean] + flags: { + pvp: boolean + explosion: boolean + fire: boolean + mobs: boolean + } + } + ranks?: { + townRanks: string[] + nationRanks: string[] + } + friends: RawEntityV3[] +} //#endregion \ No newline at end of file diff --git a/tests/oapi.test.ts b/tests/oapi.test.ts index ef28408..a9adf14 100644 --- a/tests/oapi.test.ts +++ b/tests/oapi.test.ts @@ -6,7 +6,7 @@ import { import { OfficialAPI } from '../src/main' import { OAPINation, OAPIResident, OAPITown, - RawServerInfoV2, RawServerInfoV3 + RawPlayerV3, RawServerInfoV2, RawServerInfoV3 } from '../src/types' describe('[v3] OfficialAPI', async () => { @@ -36,7 +36,7 @@ describe('[v3] OfficialAPI', async () => { const players = await OfficialAPI.V3.players("af77d9b5-ab5d-4714-b92e-3b191c895ee7") expect(players).toBeDefined() - assertType(players) + assertType(players[0]) }, 10000) }) diff --git a/tests/squaremap/nations.test.ts b/tests/squaremap/nations.test.ts index 749074f..72cd68e 100644 --- a/tests/squaremap/nations.test.ts +++ b/tests/squaremap/nations.test.ts @@ -30,7 +30,7 @@ describe('[Squaremap/Aurora] Nations', () => { }) it('can get multiple nations', async () => { - const nations = await Aurora.Nations.get('SiBeRia', 'veNICE', 'verMOnt', 'fAroe_ISlanDs') as SquaremapNation[] + const nations = await Aurora.Nations.get('SiBeRia', 'veNICE', 'verMOnt') as SquaremapNation[] expect(nations).toBeTruthy() expect(nations.length).toBe(4)