From 8cd1a70333886529d5f7f0421825b9a9202b44dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sun, 29 Oct 2023 11:54:23 -0500 Subject: [PATCH] feat: isolated tankopediaInfo --- package.json | 2 +- src/commands/ownedTanks.tsx | 2 +- src/core/blitz/tankopediaInfo.ts | 15 +++++++++++++++ src/core/blitzkrieg/filtersToDescription.ts | 7 ++----- src/core/blitzstars/tankopedia.ts | 16 ---------------- src/core/discord/addFilterOptions.ts | 2 +- 6 files changed, 20 insertions(+), 24 deletions(-) create mode 100644 src/core/blitz/tankopediaInfo.ts diff --git a/package.json b/package.json index 86789c79f..03c75bf40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.14.4", + "version": "1.15.0", "description": "🎉 Tools for everything World of Tanks Blitz", "main": "src/server.ts", "type": "module", diff --git a/src/commands/ownedTanks.tsx b/src/commands/ownedTanks.tsx index 8f731590e..242429804 100644 --- a/src/commands/ownedTanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -8,13 +8,13 @@ import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; import getTankStats from '../core/blitz/getTankStats'; import getTreeType from '../core/blitz/getTreeType'; import resolveTankName from '../core/blitz/resolveTankName'; +import { tankopediaInfo } from '../core/blitz/tankopediaInfo'; import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL'; import { TIER_ROMAN_NUMERALS, TankopediaEntry, Tier, tankopedia, - tankopediaInfo, } from '../core/blitzstars/tankopedia'; import addTierChoices from '../core/discord/addTierChoices'; import addUsernameChoices from '../core/discord/addUsernameChoices'; diff --git a/src/core/blitz/tankopediaInfo.ts b/src/core/blitz/tankopediaInfo.ts new file mode 100644 index 000000000..cc9855fea --- /dev/null +++ b/src/core/blitz/tankopediaInfo.ts @@ -0,0 +1,15 @@ +import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID'; +import fetchBlitz from './fetchBlitz'; + +export interface TankopediaInfo { + achievement_sections: Record; + tanks_updated_at: number; + languages: Record; + vehicle_types: Record; + vehicle_nations: Record; + game_version: string; +} + +export const tankopediaInfo = fetchBlitz( + `https://api.wotblitz.com/wotb/encyclopedia/info/?application_id=${WARGAMING_APPLICATION_ID}`, +); diff --git a/src/core/blitzkrieg/filtersToDescription.ts b/src/core/blitzkrieg/filtersToDescription.ts index 85d79c20d..8393ac294 100644 --- a/src/core/blitzkrieg/filtersToDescription.ts +++ b/src/core/blitzkrieg/filtersToDescription.ts @@ -1,10 +1,7 @@ import { TREE_TYPE_NAMES } from '../../components/Tanks'; import resolveTankName from '../blitz/resolveTankName'; -import { - TIER_ROMAN_NUMERALS, - Tier, - tankopediaInfo, -} from '../blitzstars/tankopedia'; +import { tankopediaInfo } from '../blitz/tankopediaInfo'; +import { TIER_ROMAN_NUMERALS, Tier } from '../blitzstars/tankopedia'; import { StatFilters } from '../statistics/filterStats'; export async function filtersToDescription({ diff --git a/src/core/blitzstars/tankopedia.ts b/src/core/blitzstars/tankopedia.ts index a21182b0e..9c00d6d2b 100644 --- a/src/core/blitzstars/tankopedia.ts +++ b/src/core/blitzstars/tankopedia.ts @@ -1,6 +1,4 @@ import { deburr } from 'lodash'; -import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID'; -import fetchBlitz from '../blitz/fetchBlitz'; import { context } from '../blitzkrieg/context'; export interface TankopediaEntry { @@ -56,20 +54,6 @@ export const TANK_NAMES_DIACRITICS = TANK_NAMES.then((tankNames) => ), ); -export interface TankopediaInfo { - achievement_sections: Record; - tanks_updated_at: number; - languages: Record; - vehicle_types: Record; - vehicle_nations: Record; - game_version: string; -} - -// this is blocking because info is needed for command creation -export const tankopediaInfo = fetchBlitz( - `https://api.wotblitz.com/wotb/encyclopedia/info/?application_id=${WARGAMING_APPLICATION_ID}`, -); - export const TANK_ICONS: Record = { 'AT-SPG': 'https://i.imgur.com/BIHSEH0.png', lightTank: 'https://i.imgur.com/CSNha5V.png', diff --git a/src/core/discord/addFilterOptions.ts b/src/core/discord/addFilterOptions.ts index 9a79642a4..9468e0484 100644 --- a/src/core/discord/addFilterOptions.ts +++ b/src/core/discord/addFilterOptions.ts @@ -4,7 +4,7 @@ import { SlashCommandSubcommandGroupBuilder, } from 'discord.js'; import { TREE_TYPE_NAMES, TreeTypeString } from '../../components/Tanks'; -import { tankopediaInfo } from '../blitzstars/tankopedia'; +import { tankopediaInfo } from '../blitz/tankopediaInfo'; import addPeriodSubCommands from './addPeriodSubCommands'; import addTankChoices from './addTankChoices'; import addTierChoices from './addTierChoices';