mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 19:19:52 +02:00
feat: voting averages
This commit is contained in:
1 parent
c3c16bf607
commit
2d2d31adf7
24 files changed
+643
-254
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { Region } from '../../constants/regions';
|
||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||
import { idToRegion } from './idToRegion';
|
||||
|
||||
export async function isValidBlitzId(id: number, token?: string) {
|
||||
let region: Region;
|
||||
|
||||
try {
|
||||
region = idToRegion(id);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const json = await fetch(
|
||||
`https://api.wotblitz.com/wotb/account/info/?account_id=${
|
||||
id
|
||||
}&application_id=${WARGAMING_APPLICATION_ID}${
|
||||
token === undefined ? '' : `&access_token=${token}`
|
||||
}&fields=account_id%2C-account_id`,
|
||||
).then(
|
||||
(response) =>
|
||||
response.json() as Promise<
|
||||
| {
|
||||
status: 'ok';
|
||||
data: Record<number, {} | null>;
|
||||
}
|
||||
| { status: 'error' }
|
||||
>,
|
||||
);
|
||||
|
||||
return json.status === 'ok' && json.data[id] !== null;
|
||||
}
|
||||
Reference in new issue
Block a user