mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
feat: made WARGAMING_APPLICATION_ID public
This commit is contained in:
1 parent
018783bb47
commit
e37e0ccf9f
31 files changed
+196
-80
No files matched your search
@@ -29,4 +29,4 @@ jobs:
|
||||
unzip bot.zip
|
||||
|
||||
- name: Run bot
|
||||
run: NODE_ENV=production GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} WARGAMING_APPLICATION_ID=${{ secrets.WARGAMING_APPLICATION_ID }} node --enable-source-maps --trace-warnings bot/index.cjs
|
||||
run: NODE_ENV=production GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} WARGAMING_APPLICATION_ID=${{ WARGAMING_APPLICATION_ID }} node --enable-source-maps --trace-warnings bot/index.cjs
|
||||
@@ -2,15 +2,20 @@
|
||||
|
||||
import { CopyIcon, ListBulletIcon, ReloadIcon } from '@radix-ui/react-icons';
|
||||
import { debounce } from 'lodash';
|
||||
import { ChangeEvent, useRef, useState } from 'react';
|
||||
import { ChangeEvent, useEffect, useRef, useState } from 'react';
|
||||
import * as Breakdown from '../../../components/Breakdown';
|
||||
import { Button } from '../../../components/Button';
|
||||
import PageWrapper from '../../../components/PageWrapper';
|
||||
import { SearchBar } from '../../../components/SearchBar';
|
||||
import { REGION_NAMES } from '../../../constants/regions';
|
||||
import { diffNormalizedTankStats } from '../../../core/blitz/diffNormalizedTankStats';
|
||||
import { AccountListWithServer } from '../../../core/blitz/listPlayers';
|
||||
import { theme } from '../../../stitches.config';
|
||||
import { useSession } from '../../../stores/session';
|
||||
import { NormalizedTankStats } from '../../../types/tanksStats';
|
||||
import {
|
||||
IndividualTankStats,
|
||||
NormalizedTankStats,
|
||||
} from '../../../types/tanksStats';
|
||||
import * as styles from './page.css';
|
||||
|
||||
export default function Page() {
|
||||
@@ -33,7 +38,21 @@ export default function Page() {
|
||||
},
|
||||
500,
|
||||
);
|
||||
const initialSession = useSession.getState();
|
||||
const session = useSession();
|
||||
const [diff, setDiff] = useState<NormalizedTankStats | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (session.isTracking) {
|
||||
const { id, region } = session;
|
||||
const current = await fetch(
|
||||
`/api/stats/normalized/tanks?id=${id}®ion=${region}`,
|
||||
).then((response) => response.json() as Promise<NormalizedTankStats>);
|
||||
|
||||
setDiff(diffNormalizedTankStats(session.tankStats, current));
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PageWrapper>
|
||||
@@ -42,9 +61,7 @@ export default function Page() {
|
||||
<SearchBar
|
||||
ref={input}
|
||||
style={{ width: '100%', boxSizing: 'border-box' }}
|
||||
defaultValue={
|
||||
initialSession.isTracking ? initialSession.nickname : undefined
|
||||
}
|
||||
defaultValue={session.isTracking ? session.nickname : undefined}
|
||||
onChange={(event) => {
|
||||
if (event.target.value) {
|
||||
setShowSearchResults(true);
|
||||
@@ -175,6 +192,13 @@ export default function Page() {
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Breakdown.Root>
|
||||
{diff &&
|
||||
(Object.entries(diff) as [string, IndividualTankStats][])
|
||||
.sort(([, a], [, b]) => b.last_battle_time - a.last_battle_time)
|
||||
.map(([id, tankStats]) => <Breakdown.Row key={id} />)}
|
||||
</Breakdown.Root>
|
||||
</PageWrapper>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { SlashCommandBuilder, escapeMarkdown } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import { PlayerHistoriesRaw } from '../core/blitzstars/getPlayerHistories';
|
||||
import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo';
|
||||
@@ -7,7 +8,6 @@ import addClanChoices from '../core/discord/addClanChoices';
|
||||
import autocompleteClan from '../core/discord/autocompleteClan';
|
||||
import embedWarning from '../core/discord/embedWarning';
|
||||
import resolveClanFromCommand from '../core/discord/resolveClanFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import { AccountAchievements } from '../types/accountAchievements';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
@@ -26,16 +26,16 @@ export const clanEventCommand: CommandRegistry = {
|
||||
const { region, id } = await resolveClanFromCommand(interaction);
|
||||
const clan = (
|
||||
await getWargamingResponse<ClanInfo>(
|
||||
`https://api.wotblitz.${region}/wotb/clans/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&clan_id=${id}`,
|
||||
`https://api.wotblitz.${region}/wotb/clans/info/?application_id=${WARGAMING_APPLICATION_ID}&clan_id=${id}`,
|
||||
)
|
||||
)[id];
|
||||
const memberIds = clan.members_ids.join(',');
|
||||
const [players, achievements, previousJointVictories] = await Promise.all([
|
||||
getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${memberIds}`,
|
||||
`https://api.wotblitz.${region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${memberIds}`,
|
||||
),
|
||||
getWargamingResponse<AccountAchievements>(
|
||||
`https://api.wotblitz.${region}/wotb/account/achievements/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${memberIds}`,
|
||||
`https://api.wotblitz.${region}/wotb/account/achievements/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${memberIds}`,
|
||||
),
|
||||
Promise.all(
|
||||
clan.members_ids.map((id) =>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import calculateWN8 from '../core/blitz/calculateWN8';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import sumStats from '../core/blitz/sumStats';
|
||||
@@ -12,7 +13,6 @@ import embedNegative from '../core/discord/embedNegative';
|
||||
import embedPositive from '../core/discord/embedPositive';
|
||||
import markdownTable, { TableInput } from '../core/discord/markdownTable';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
import { PossiblyPromise } from '../types/possiblyPromise';
|
||||
@@ -50,7 +50,7 @@ export const eligibleCommand: CommandRegistry = {
|
||||
const clan = interaction.options.getString('clan') as SkilledClan;
|
||||
const { id, region: server } = await resolvePlayerFromCommand(interaction);
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const problems: TableInput = [];
|
||||
const title = `${accountInfo[id].nickname}'s eligibility for ${SKILLED_CLANS[clan]}`;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { CYCLIC_API } from '../constants/cyclic';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import resolveTankId from '../core/blitz/resolveTankId';
|
||||
import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups';
|
||||
@@ -12,7 +13,6 @@ import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton';
|
||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistryRaw } from '../events/interactionCreate';
|
||||
import evolution from '../renderers/evolution';
|
||||
import { StatType } from '../renderers/stats';
|
||||
@@ -46,7 +46,7 @@ export const evolutionCommand = new Promise<CommandRegistryRaw>(
|
||||
const end = interaction.options.getInteger('end');
|
||||
const { nickname } = (
|
||||
await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
)
|
||||
)[player.id];
|
||||
const path = interactionToURL(interaction, {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { TreeTypeString } from '../components/Tanks';
|
||||
import { CYCLIC_API } from '../constants/cyclic';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import resolveTankId from '../core/blitz/resolveTankId';
|
||||
import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups';
|
||||
@@ -13,7 +14,6 @@ import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton';
|
||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistryRaw } from '../events/interactionCreate';
|
||||
import fullStats from '../renderers/fullStats';
|
||||
import { MultiTankFilters, StatType } from '../renderers/stats';
|
||||
@@ -57,7 +57,7 @@ export const fullStatsCommand = new Promise<CommandRegistryRaw>(
|
||||
});
|
||||
const { nickname } = (
|
||||
await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
)
|
||||
)[player.id];
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ import GenericStats from '../components/GenericStats';
|
||||
import NoData, { NoDataType } from '../components/NoData';
|
||||
import TitleBar from '../components/TitleBar';
|
||||
import Wrapper from '../components/Wrapper';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import addClanChoices from '../core/discord/addClanChoices';
|
||||
import autocompleteClan from '../core/discord/autocompleteClan';
|
||||
import resolveClanFromCommand from '../core/discord/resolveClanFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
import { ClanInfo } from '../types/clanInfo';
|
||||
@@ -38,14 +38,14 @@ export const inactiveCommand: CommandRegistry = {
|
||||
const time = new Date().getTime() / 1000;
|
||||
const clanData = (
|
||||
await getWargamingResponse<ClanInfo>(
|
||||
`https://api.wotblitz.${region}/wotb/clans/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&clan_id=${id}`,
|
||||
`https://api.wotblitz.${region}/wotb/clans/info/?application_id=${WARGAMING_APPLICATION_ID}&clan_id=${id}`,
|
||||
)
|
||||
)[id];
|
||||
const memberIds = clanData.members_ids;
|
||||
const accounts = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${region}/wotb/account/info/?application_id=${
|
||||
secrets.WARGAMING_APPLICATION_ID
|
||||
}&account_id=${memberIds.join(',')}`,
|
||||
`https://api.wotblitz.${region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${memberIds.join(
|
||||
',',
|
||||
)}`,
|
||||
);
|
||||
const inactive = memberIds
|
||||
.map((memberId) => {
|
||||
|
||||
@@ -3,6 +3,7 @@ import NoData, { NoDataType } from '../components/NoData';
|
||||
import * as Tanks from '../components/Tanks';
|
||||
import TitleBar from '../components/TitleBar';
|
||||
import Wrapper from '../components/Wrapper';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getTankStats from '../core/blitz/getTankStats';
|
||||
import getTreeType from '../core/blitz/getTreeType';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
@@ -18,7 +19,6 @@ import addTierChoices from '../core/discord/addTierChoices';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
import { PlayerClanData } from '../types/playerClanData';
|
||||
@@ -59,7 +59,7 @@ export const ownedTanksCommand: CommandRegistry = {
|
||||
const account = await resolvePlayerFromCommand(interaction);
|
||||
const { id, region: server } = account;
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const tankStats = await getTankStats(server, id);
|
||||
const filteredTanks = (
|
||||
@@ -71,7 +71,7 @@ export const ownedTanksCommand: CommandRegistry = {
|
||||
)
|
||||
).filter((tank) => tank.tankopedia?.tier === tier);
|
||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
);
|
||||
const groupedTanks: Record<string, TankopediaEntry[]> = {};
|
||||
const nations: string[] = [];
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { startCase } from 'lodash';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||
import embedInfo from '../core/discord/embedInfo';
|
||||
import markdownTable, { TableInputEntry } from '../core/discord/markdownTable';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import { AccountAchievements } from '../types/accountAchievements';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
@@ -37,11 +37,11 @@ export const playerAchievementsCommand: CommandRegistry = {
|
||||
const account = await resolvePlayerFromCommand(interaction);
|
||||
const { id, region: server } = account;
|
||||
const accounts = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const accountsAchievements =
|
||||
await getWargamingResponse<AccountAchievements>(
|
||||
`https://api.wotblitz.${server}/wotb/account/achievements/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/achievements/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const accountAchievements = accountsAchievements[id];
|
||||
const compound = {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||
import embedInfo from '../core/discord/embedInfo';
|
||||
import markdownTable from '../core/discord/markdownTable';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
|
||||
@@ -23,7 +23,7 @@ export const playerInfoCommand: CommandRegistry = {
|
||||
const account = await resolvePlayerFromCommand(interaction);
|
||||
const { id, region: server } = account;
|
||||
const accounts = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const accountInfo = accounts[id];
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import * as Leaderboard from '../components/Leaderboard';
|
||||
import TitleBar from '../components/TitleBar';
|
||||
import Wrapper from '../components/Wrapper';
|
||||
import { REGION_NAMES_SHORT, Region } from '../constants/regions';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getArchivedRatingsInfo from '../core/blitz/getArchivedRatingsInfo';
|
||||
import getRatingsInfo from '../core/blitz/getRatingsInfo';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
@@ -21,7 +22,6 @@ import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { octokit } from '../core/express/octokit';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import throwError from '../core/node/throwError';
|
||||
import { CommandRegistryRaw } from '../events/interactionCreate';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
@@ -307,7 +307,7 @@ export const ratingsCommand = new Promise<CommandRegistryRaw>(
|
||||
);
|
||||
const ids = trimmed.map((player) => player.id).join(',');
|
||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${region}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${ids}&extra=clan`,
|
||||
`https://api.wotblitz.${region}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${ids}&extra=clan`,
|
||||
);
|
||||
|
||||
return trimmed.map(
|
||||
@@ -371,11 +371,11 @@ export const ratingsCommand = new Promise<CommandRegistryRaw>(
|
||||
)) as RatingsInfo;
|
||||
});
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const clan = (
|
||||
await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${region}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
`https://api.wotblitz.${region}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
)
|
||||
)[id]?.clan;
|
||||
const regionSubdomain = regionToRegionSubdomain(region);
|
||||
@@ -438,7 +438,7 @@ export const ratingsCommand = new Promise<CommandRegistryRaw>(
|
||||
);
|
||||
const ids = trimmed.map((player) => player.id).join(',');
|
||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${region}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${ids}&extra=clan`,
|
||||
`https://api.wotblitz.${region}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${ids}&extra=clan`,
|
||||
);
|
||||
|
||||
return trimmed.map((player, index) => ({
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { REGION_NAMES, Region } from '../constants/regions';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import addClanChoices from '../core/discord/addClanChoices';
|
||||
import addRegionChoices from '../core/discord/addRegionChoices';
|
||||
import embedInfo from '../core/discord/embedInfo';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import { ClanList } from '../types/clanList';
|
||||
|
||||
@@ -31,7 +31,7 @@ export const searchClansCommand: CommandRegistry = {
|
||||
const clan = interaction.options.getString('clan')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
const clanList = await getWargamingResponse<ClanList>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${clan}&limit=${limit}`,
|
||||
`https://api.wotblitz.${server}/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${clan}&limit=${limit}`,
|
||||
);
|
||||
|
||||
return embedInfo(
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { REGION_NAMES, Region } from '../constants/regions';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import { usernamePattern } from '../core/blitz/listPlayers';
|
||||
import addRegionChoices from '../core/discord/addRegionChoices';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||
import embedInfo from '../core/discord/embedInfo';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import { AccountList } from '../types/accountList';
|
||||
|
||||
@@ -36,9 +36,9 @@ export const searchPlayersCommand: CommandRegistry = {
|
||||
const trimmedSearch = name.trim();
|
||||
const players = usernamePattern.test(trimmedSearch)
|
||||
? await getWargamingResponse<AccountList>(
|
||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${
|
||||
secrets.WARGAMING_APPLICATION_ID
|
||||
}&search=${encodeURIComponent(trimmedSearch)}&limit=${limit}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodeURIComponent(
|
||||
trimmedSearch,
|
||||
)}&limit=${limit}`,
|
||||
)
|
||||
: [];
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { TreeTypeString } from '../components/Tanks';
|
||||
import { CYCLIC_API } from '../constants/cyclic';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import resolveTankId from '../core/blitz/resolveTankId';
|
||||
import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups';
|
||||
@@ -13,7 +14,6 @@ import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton';
|
||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistryRaw } from '../events/interactionCreate';
|
||||
import stats, { MultiTankFilters, StatType } from '../renderers/stats';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
@@ -55,7 +55,7 @@ export const statsCommand = new Promise<CommandRegistryRaw>(async (resolve) => {
|
||||
});
|
||||
const { nickname } = (
|
||||
await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
)
|
||||
)[player.id];
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||
@@ -7,7 +8,6 @@ import linkButton from '../core/discord/linkButton';
|
||||
import primaryButton from '../core/discord/primaryButton';
|
||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import today from '../renderers/today';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
@@ -52,7 +52,7 @@ export const todayCommand: CommandRegistry = {
|
||||
const showTotal = interaction.options.getBoolean('show-total') ?? undefined;
|
||||
const { nickname } = (
|
||||
await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
)
|
||||
)[player.id];
|
||||
const path = interactionToURL(interaction, {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||
import embedNegative from '../core/discord/embedNegative';
|
||||
import embedPositive from '../core/discord/embedPositive';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
import { PlayerClanData } from '../types/playerClanData';
|
||||
@@ -25,10 +25,10 @@ export const verifyCommand: CommandRegistry = {
|
||||
const blitzAccount = await resolvePlayerFromCommand(interaction);
|
||||
const { id, region: server } = blitzAccount;
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
);
|
||||
const clan = clanData[id]?.clan;
|
||||
const clanTag = clan ? ` [${clan!.tag}]` : '';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from './components/Root';
|
||||
export * from './components/Row';
|
||||
export * from './components/RowStat';
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// if you forked this repository, please replace this with your own id
|
||||
export const WARGAMING_APPLICATION_ID = 'd03364bdc9114fc61f1d5e4e168d5f3c';
|
||||
@@ -0,0 +1,66 @@
|
||||
import {
|
||||
IndividualTankStats,
|
||||
NormalizedTankStats,
|
||||
emptyIndividualTankStats,
|
||||
} from '../../types/tanksStats';
|
||||
|
||||
export function diffNormalizedTankStats(
|
||||
a: NormalizedTankStats,
|
||||
b: NormalizedTankStats,
|
||||
) {
|
||||
const bTanks = Object.keys(b);
|
||||
const changedTanks = bTanks.filter((id) => {
|
||||
return (
|
||||
a[id as unknown as number]?.all.battles !==
|
||||
b[id as unknown as number].all.battles
|
||||
);
|
||||
});
|
||||
const diff = changedTanks.map((id) => {
|
||||
const aTank = a[id as unknown as number] ?? emptyIndividualTankStats;
|
||||
const bTank = b[id as unknown as number];
|
||||
|
||||
const tankDiff = {
|
||||
account_id: bTank.account_id,
|
||||
battle_life_time: bTank.battle_life_time,
|
||||
frags: (bTank.frags ?? aTank.frags ?? 0) - (aTank.frags ?? 0),
|
||||
max_frags: Math.max(aTank.max_frags, bTank.max_frags),
|
||||
in_garage: bTank.in_garage,
|
||||
max_xp: Math.max(aTank.max_xp, bTank.max_xp),
|
||||
in_garage_updated: bTank.in_garage_updated,
|
||||
last_battle_time: bTank.last_battle_time - aTank.last_battle_time,
|
||||
mark_of_mastery: bTank.mark_of_mastery,
|
||||
tank_id: bTank.tank_id,
|
||||
|
||||
all: {
|
||||
battles: bTank.all.battles - aTank.all.battles,
|
||||
wins: bTank.all.wins - aTank.all.wins,
|
||||
capture_points: bTank.all.capture_points - aTank.all.capture_points,
|
||||
damage_dealt: bTank.all.damage_dealt - aTank.all.damage_dealt,
|
||||
damage_received: bTank.all.damage_received - aTank.all.damage_received,
|
||||
dropped_capture_points:
|
||||
bTank.all.dropped_capture_points - aTank.all.dropped_capture_points,
|
||||
frags: bTank.all.frags - aTank.all.frags,
|
||||
frags8p: bTank.all.frags8p - aTank.all.frags8p,
|
||||
hits: bTank.all.hits - aTank.all.hits,
|
||||
losses: bTank.all.losses - aTank.all.losses,
|
||||
max_frags: Math.max(aTank.max_frags, bTank.max_frags),
|
||||
max_xp: Math.max(aTank.max_xp, bTank.max_xp),
|
||||
shots: bTank.all.shots - aTank.all.shots,
|
||||
spotted: bTank.all.spotted - aTank.all.spotted,
|
||||
survived_battles:
|
||||
bTank.all.survived_battles - aTank.all.survived_battles,
|
||||
win_and_survived:
|
||||
bTank.all.win_and_survived - aTank.all.win_and_survived,
|
||||
xp: bTank.all.xp - aTank.all.xp,
|
||||
},
|
||||
} satisfies IndividualTankStats;
|
||||
|
||||
return tankDiff;
|
||||
});
|
||||
const normalized = diff.reduce<NormalizedTankStats>(
|
||||
(accumulator, diff) => ({ ...accumulator, [diff.tank_id]: diff }),
|
||||
{},
|
||||
);
|
||||
|
||||
return normalized;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { REGION_NAMES, Region } from '../../constants/regions';
|
||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||
import { TankStats } from '../../types/tanksStats';
|
||||
import { secrets } from '../node/secrets';
|
||||
import throwError from '../node/throwError';
|
||||
import getWargamingResponse from './getWargamingResponse';
|
||||
|
||||
export default async function getTankStats(region: Region, id: number) {
|
||||
const tankStats = await getWargamingResponse<TankStats>(
|
||||
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
|
||||
if (tankStats[id] === null) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Region } from '../../constants/regions';
|
||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||
import { Clan, ClanList } from '../../types/clanList';
|
||||
import { secrets } from '../node/secrets';
|
||||
import getWargamingResponse from './getWargamingResponse';
|
||||
|
||||
export type ClanListWithRegion = (Clan & {
|
||||
@@ -15,7 +15,7 @@ export default async function listClans(search: string, limit = 9) {
|
||||
return (
|
||||
await Promise.all([
|
||||
getWargamingResponse<ClanList>(
|
||||
`https://api.wotblitz.com/wotb/clans/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||
`https://api.wotblitz.com/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||
).then(
|
||||
(value) =>
|
||||
value &&
|
||||
@@ -25,7 +25,7 @@ export default async function listClans(search: string, limit = 9) {
|
||||
})),
|
||||
),
|
||||
getWargamingResponse<ClanList>(
|
||||
`https://api.wotblitz.eu/wotb/clans/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||
`https://api.wotblitz.eu/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||
).then(
|
||||
(value) =>
|
||||
value &&
|
||||
@@ -35,7 +35,7 @@ export default async function listClans(search: string, limit = 9) {
|
||||
})),
|
||||
),
|
||||
getWargamingResponse<ClanList>(
|
||||
`https://api.wotblitz.asia/wotb/clans/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||
`https://api.wotblitz.asia/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||
).then(
|
||||
(value) =>
|
||||
value &&
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Region } from '../../constants/regions';
|
||||
import { secrets } from '../node/secrets';
|
||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from './getWargamingResponse';
|
||||
|
||||
interface Account {
|
||||
@@ -23,7 +23,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
||||
return (
|
||||
await Promise.all([
|
||||
getWargamingResponse<AccountList>(
|
||||
`https://api.wotblitz.com/wotb/account/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||
`https://api.wotblitz.com/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||
).then(
|
||||
(value) =>
|
||||
value &&
|
||||
@@ -33,7 +33,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
||||
})),
|
||||
),
|
||||
getWargamingResponse<AccountList>(
|
||||
`https://api.wotblitz.eu/wotb/account/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||
`https://api.wotblitz.eu/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||
).then(
|
||||
(value) =>
|
||||
value &&
|
||||
@@ -43,7 +43,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
||||
})),
|
||||
),
|
||||
getWargamingResponse<AccountList>(
|
||||
`https://api.wotblitz.asia/wotb/account/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||
`https://api.wotblitz.asia/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||
).then(
|
||||
(value) =>
|
||||
value &&
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { deburr } from 'lodash';
|
||||
import { secrets } from '../node/secrets';
|
||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||
import getWargamingResponse from './getWargamingResponse';
|
||||
|
||||
export type TankType = 'AT-SPG' | 'lightTank' | 'mediumTank' | 'heavyTank';
|
||||
@@ -66,7 +66,7 @@ export interface TankopediaInfo {
|
||||
// this is blocking because info is needed for command creation
|
||||
console.log('Caching tankopedia info...');
|
||||
export const tankopediaInfo = getWargamingResponse<TankopediaInfo>(
|
||||
`https://api.wotblitz.com/wotb/encyclopedia/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}`,
|
||||
`https://api.wotblitz.com/wotb/encyclopedia/info/?application_id=${WARGAMING_APPLICATION_ID}`,
|
||||
);
|
||||
console.log('Cached tankopedia info');
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ export const emptyTankHistoryNode: TankHistoryRaw = {
|
||||
all: emptyAllStats,
|
||||
};
|
||||
|
||||
// BIG TODO: merge this neatly with diffNormalizedTankStats
|
||||
export default async function getDiffedTankStats(
|
||||
server: Region,
|
||||
id: number,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Region } from '../../constants/regions';
|
||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||
import { AccountInfo, AllStats } from '../../types/accountInfo';
|
||||
import {
|
||||
GetHistoriesOptions,
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
getHistoriesDefaultOptions,
|
||||
} from '../../types/histories';
|
||||
import getWargamingResponse from '../blitz/getWargamingResponse';
|
||||
import { secrets } from '../node/secrets';
|
||||
import { emptyAllStats } from './getDiffedTankStats';
|
||||
|
||||
export interface PlayerHistoryRaw {
|
||||
@@ -67,7 +67,7 @@ export default async function getPlayerHistories(
|
||||
statistics: { all },
|
||||
} = (
|
||||
await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
)
|
||||
)[id];
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@ import { config } from 'dotenv';
|
||||
|
||||
config();
|
||||
|
||||
export const SECRET_KEYS = [
|
||||
'DISCORD_TOKEN',
|
||||
'WARGAMING_APPLICATION_ID',
|
||||
'GH_TOKEN',
|
||||
] as const;
|
||||
export const SECRET_KEYS = ['DISCORD_TOKEN', 'GH_TOKEN'] as const;
|
||||
|
||||
export type SECRET = typeof SECRET_KEYS extends readonly (infer T)[]
|
||||
? T
|
||||
|
||||
@@ -9,7 +9,6 @@ import getPlayerHistories from '../core/blitzstars/getPlayerHistories';
|
||||
import getTankHistories from '../core/blitzstars/getTankHistories';
|
||||
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
|
||||
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { AccountInfo } from '../types/accountInfo';
|
||||
import { Histories } from '../types/histories';
|
||||
import { PlayerClanData } from '../types/playerClanData';
|
||||
@@ -27,7 +26,7 @@ export default async function evolution<Type extends StatType>(
|
||||
if (type === 'player') {
|
||||
const clan = (
|
||||
await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
)
|
||||
)[id]?.clan;
|
||||
|
||||
@@ -77,7 +76,7 @@ export default async function evolution<Type extends StatType>(
|
||||
const minX = Math.min(...xs);
|
||||
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -12,7 +12,6 @@ import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats';
|
||||
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
|
||||
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import {
|
||||
AccountInfo,
|
||||
AllStats,
|
||||
@@ -37,7 +36,7 @@ export default async function fullStats<Type extends StatType>(
|
||||
if (type === 'player' || type === 'multi-tank') {
|
||||
const clan = (
|
||||
await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
)
|
||||
)[id]?.clan;
|
||||
|
||||
@@ -141,7 +140,7 @@ export default async function fullStats<Type extends StatType>(
|
||||
}
|
||||
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -12,7 +12,6 @@ import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats';
|
||||
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
|
||||
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { theme } from '../stitches.config';
|
||||
import {
|
||||
AccountInfo,
|
||||
@@ -47,7 +46,7 @@ export default async function stats<Type extends StatType>(
|
||||
if (type === 'player' || type === 'multi-tank') {
|
||||
const clan = (
|
||||
await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
)
|
||||
)[id]?.clan;
|
||||
|
||||
@@ -136,7 +135,7 @@ export default async function stats<Type extends StatType>(
|
||||
}
|
||||
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const overview = (
|
||||
<AllStatsOverview stats={stats} supplementaryStats={supplementaryStats} />
|
||||
|
||||
@@ -14,7 +14,6 @@ import getPeriodNow from '../core/blitzstars/getPeriodNow';
|
||||
import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo';
|
||||
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
||||
import { secrets } from '../core/node/secrets';
|
||||
import { AccountInfo, AllStats } from '../types/accountInfo';
|
||||
import { PlayerClanData } from '../types/playerClanData';
|
||||
import { PossiblyPromise } from '../types/possiblyPromise';
|
||||
@@ -33,10 +32,10 @@ export default async function today(
|
||||
getPeriodNow(),
|
||||
);
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
);
|
||||
const careerTankStatsRaw = await getTankStats(server, id);
|
||||
const careerStats: Record<number, AllStats> = showTotal
|
||||
|
||||
@@ -21,3 +21,35 @@ export interface TankStats {
|
||||
export interface NormalizedTankStats {
|
||||
[tankId: number]: IndividualTankStats;
|
||||
}
|
||||
|
||||
export const emptyIndividualTankStats: IndividualTankStats = {
|
||||
all: {
|
||||
battles: 0,
|
||||
capture_points: 0,
|
||||
damage_dealt: 0,
|
||||
damage_received: 0,
|
||||
dropped_capture_points: 0,
|
||||
frags: 0,
|
||||
frags8p: 0,
|
||||
hits: 0,
|
||||
losses: 0,
|
||||
max_frags: 0,
|
||||
max_xp: 0,
|
||||
shots: 0,
|
||||
spotted: 0,
|
||||
survived_battles: 0,
|
||||
xp: 0,
|
||||
win_and_survived: 0,
|
||||
wins: 0,
|
||||
},
|
||||
last_battle_time: 0,
|
||||
account_id: 0,
|
||||
max_xp: 0,
|
||||
in_garage_updated: 0,
|
||||
max_frags: 0,
|
||||
frags: 0,
|
||||
battle_life_time: 0,
|
||||
in_garage: 0,
|
||||
tank_id: 0,
|
||||
mark_of_mastery: 0,
|
||||
};
|
||||
Reference in new issue
Block a user