mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
feat: added ratings leaderboard generation and publication
This commit is contained in:
1 parent
098e6c09b9
commit
6d9e6973d5
35 files changed
+412
-84
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { BlitzServer } from '../../constants/servers';
|
||||
import { RegionDomain } from '../../constants/regions';
|
||||
import { serverAndIdPattern } from '../discord/resolvePlayerFromCommand';
|
||||
import throwError from '../node/throwError';
|
||||
import listClans from './listClans';
|
||||
@@ -6,7 +6,7 @@ import listClans from './listClans';
|
||||
export default async function getBlitzClan(clan: string) {
|
||||
if (serverAndIdPattern.test(clan)) {
|
||||
const [server, accountId] = clan.split('/');
|
||||
return { server: server as BlitzServer, id: Number(accountId) };
|
||||
return { server: server as RegionDomain, id: Number(accountId) };
|
||||
} else {
|
||||
const accounts = await listClans(clan);
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { BLITZ_SERVERS, BlitzServer } from '../../constants/servers';
|
||||
import { REGION_DOMAIN_NAMES, RegionDomain } from '../../constants/regions';
|
||||
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: BlitzServer, id: number) {
|
||||
export default async function getTankStats(server: RegionDomain, id: number) {
|
||||
const tankStats = await getWargamingResponse<TanksStats>(
|
||||
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
@@ -12,7 +12,7 @@ export default async function getTankStats(server: BlitzServer, id: number) {
|
||||
if (tankStats[id] === null) {
|
||||
throw throwError(
|
||||
'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 ${BLITZ_SERVERS[server]} server.`,
|
||||
`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.`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BlitzServer } from '../../constants/servers';
|
||||
import { RegionDomain } from '../../constants/regions';
|
||||
import { Clan, ClanList } from '../../types/clanList';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments';
|
||||
import getWargamingResponse from './getWargamingResponse';
|
||||
@@ -21,7 +21,7 @@ export default async function listClans(search: string, limit = 9) {
|
||||
value &&
|
||||
value.map((account) => ({
|
||||
...account,
|
||||
server: 'com' as BlitzServer,
|
||||
server: 'com' as RegionDomain,
|
||||
})),
|
||||
),
|
||||
getWargamingResponse<ClanList>(
|
||||
@@ -31,7 +31,7 @@ export default async function listClans(search: string, limit = 9) {
|
||||
value &&
|
||||
value.map((account) => ({
|
||||
...account,
|
||||
server: 'eu' as BlitzServer,
|
||||
server: 'eu' as RegionDomain,
|
||||
})),
|
||||
),
|
||||
getWargamingResponse<ClanList>(
|
||||
@@ -41,7 +41,7 @@ export default async function listClans(search: string, limit = 9) {
|
||||
value &&
|
||||
value.map((account) => ({
|
||||
...account,
|
||||
server: 'asia' as BlitzServer,
|
||||
server: 'asia' as RegionDomain,
|
||||
})),
|
||||
),
|
||||
])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BlitzServer } from '../../constants/servers';
|
||||
import { RegionDomain } from '../../constants/regions';
|
||||
import { Account, AccountList } from '../../types/accountList';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments';
|
||||
import getWargamingResponse from './getWargamingResponse';
|
||||
@@ -25,7 +25,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
||||
value &&
|
||||
value.map((account) => ({
|
||||
...account,
|
||||
server: 'com' as BlitzServer,
|
||||
server: 'com' as RegionDomain,
|
||||
})),
|
||||
),
|
||||
getWargamingResponse<AccountList>(
|
||||
@@ -35,7 +35,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
||||
value &&
|
||||
value.map((account) => ({
|
||||
...account,
|
||||
server: 'eu' as BlitzServer,
|
||||
server: 'eu' as RegionDomain,
|
||||
})),
|
||||
),
|
||||
getWargamingResponse<AccountList>(
|
||||
@@ -45,7 +45,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
||||
value &&
|
||||
value.map((account) => ({
|
||||
...account,
|
||||
server: 'asia' as BlitzServer,
|
||||
server: 'asia' as RegionDomain,
|
||||
})),
|
||||
),
|
||||
])
|
||||
|
||||
Reference in new issue
Block a user