Files
blitzkit/src/core/blitz/getTankStats.ts
T

20 lines
847 B
TypeScript
Raw Normal View History

import { REGION_DOMAIN_NAMES, RegionDomain } from '../../constants/regions';
2023-07-11 19:54:57 +00:00
import { TanksStats } from '../../types/tanksStats';
import { WARGAMING_APPLICATION_ID } from '../node/arguments';
import throwError from '../node/throwError';
import getWargamingResponse from './getWargamingResponse';
export default async function getTankStats(server: RegionDomain, id: number) {
const tankStats = await getWargamingResponse<TanksStats>(
2023-06-12 01:17:26 +00:00
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
);
if (tankStats[id] === null) {
2023-06-27 17:22:27 +00:00
throw throwError(
2023-06-06 16:50:33 +00:00
'No tank stats available',
`Wargaming says there is no tank stats for this account. This account may not have any battles/tanks or exist in the ${REGION_DOMAIN_NAMES[server]} server.`,
2023-06-06 16:50:33 +00:00
);
}
return tankStats[id];
}