diff --git a/src/OAPI.ts b/src/OAPI.ts index d3276f3..d6a4cec 100644 --- a/src/OAPI.ts +++ b/src/OAPI.ts @@ -108,7 +108,10 @@ export class OAPIV3 { static discord = async (...objs: DiscordReqObject[]): Promise => await townyData('/discord', 'v3', { query: objs }) - static players = async (...ids: string[]): Promise => + static playerList = async (): Promise<{ name: string, uuid: string }[]> => + await townyData('/players', 'v3') + + static players = async (...ids: string[]): Promise => await townyData('/players', 'v3', { query: ids }) } diff --git a/tests/oapi.test.ts b/tests/oapi.test.ts index 6d69b25..2b7c992 100644 --- a/tests/oapi.test.ts +++ b/tests/oapi.test.ts @@ -24,6 +24,22 @@ describe('[v3] OfficialAPI', async () => { expect(info.stats.numTowns).toBeGreaterThanOrEqual(1000) expect(info.stats.numNations).toBeGreaterThanOrEqual(100) }, 10000) + + it('can get player list', async () => { + const playerList = await OfficialAPI.V3.playerList() + + expect(playerList).toBeDefined() + assertType<{ name: string, uuid: string }[]>(playerList) + }, 10000) + + it('can get valid player info', async () => { + const players = await OfficialAPI.V3.players("af77d9b5-ab5d-4714-b92e-3b191c895ee7") + + console.log(players) + + expect(players).toBeDefined() + assertType(players) + }, 10000) }) describe('[v2] OfficialAPI', async () => {