From 2258b0f93642b2a6aee4e03db4ec3fa92bd2c904 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Fri, 7 Jul 2023 01:29:13 +0000 Subject: [PATCH 01/26] fix: extra tilda --- docs/changelogs/1.9.5.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelogs/1.9.5.md b/docs/changelogs/1.9.5.md index 72913004c..f42e89242 100644 --- a/docs/changelogs/1.9.5.md +++ b/docs/changelogs/1.9.5.md @@ -1,6 +1,6 @@ # Blitzkrieg 1.9.5 -Hopefully this is the last round of fixes for Blitzkrieg `1.9``. +Hopefully this is the last round of fixes for Blitzkrieg `1.9`. ## Fixes From 57271e3c23792586f6564a3eeab1a0adb3dd3b8d Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sat, 8 Jul 2023 19:39:35 +0000 Subject: [PATCH 02/26] feat: infrastructure for ownedtanks columns --- .gitignore | 3 ++- package.json | 2 +- src/commands/debug.ts | 2 +- src/commands/eligible.ts | 2 +- src/commands/evolution.tsx | 5 +++-- src/commands/help.ts | 2 +- src/commands/inactive.tsx | 2 +- src/commands/ownedTanks.tsx | 4 ++++ src/commands/ping.ts | 2 +- src/commands/playerAchievements.ts | 2 +- src/commands/playerInfo.ts | 2 +- src/commands/searchClans.ts | 2 +- src/commands/searchPlayers.ts | 2 +- src/commands/searchTanks.ts | 2 +- src/commands/stats.tsx | 2 +- src/commands/statsFull.tsx | 2 +- src/commands/today.tsx | 2 +- src/commands/verify.ts | 2 +- src/routes/stats.tsx | 2 +- 19 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 2d75ee75a..bf0f85c9c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ dist.zip commands.txt /test.* /docs/.vitepress/dist -/docs/.vitepress/cache \ No newline at end of file +/docs/.vitepress/cache +servers.csv \ No newline at end of file diff --git a/package.json b/package.json index 324cdd060..f01ffccb2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.9.4", + "version": "1.10.0", "description": "", "main": "src/server.ts", "type": "module", diff --git a/src/commands/debug.ts b/src/commands/debug.ts index 77af7954d..59a47d30b 100644 --- a/src/commands/debug.ts +++ b/src/commands/debug.ts @@ -12,7 +12,7 @@ const executionStart = new Date().getTime(); export const debugCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/eligible.ts b/src/commands/eligible.ts index dca377759..2df78fe04 100644 --- a/src/commands/eligible.ts +++ b/src/commands/eligible.ts @@ -26,7 +26,7 @@ export const SKILLED_CLANS: Record = { export const eligibleCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: false, command: new SlashCommandBuilder() diff --git a/src/commands/evolution.tsx b/src/commands/evolution.tsx index 3187aab66..e9f2253f2 100644 --- a/src/commands/evolution.tsx +++ b/src/commands/evolution.tsx @@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const evolutionCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: addStatTypeSubCommandGroups( @@ -36,7 +36,8 @@ export const evolutionCommand: CommandRegistry = { const player = await resolvePlayerFromCommand(interaction); const period = resolvePeriodFromCommand(interaction); const tankIdRaw = interaction.options.getString('tank')!; - const tankId = commandGroup === 'tank' ? await resolveTankId(tankIdRaw) : null; + const tankId = + commandGroup === 'tank' ? await resolveTankId(tankIdRaw) : null; const start = interaction.options.getInteger('start'); const end = interaction.options.getInteger('end'); const { nickname } = ( diff --git a/src/commands/help.ts b/src/commands/help.ts index 164acd3df..408fe78b7 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -10,7 +10,7 @@ import { export const helpCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/inactive.tsx b/src/commands/inactive.tsx index 0dc891f13..987f6568d 100644 --- a/src/commands/inactive.tsx +++ b/src/commands/inactive.tsx @@ -18,7 +18,7 @@ const DEFAULT_THRESHOLD = 7; export const inactiveCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/ownedTanks.tsx b/src/commands/ownedTanks.tsx index 3688ed767..752ba3d56 100644 --- a/src/commands/ownedTanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -89,6 +89,10 @@ export const ownedTanksCommand: CommandRegistry = { const clanData = await getWargamingResponse( `https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`, ); + const leftColumnSize = Math.ceil(tanks.length / 2); + const rightColumnSize = tanks.length - leftColumnSize; + const leftColumn = tanks.slice(0, leftColumnSize); + const rightColumn = tanks.slice(leftColumnSize); return ( diff --git a/src/commands/ping.ts b/src/commands/ping.ts index bcaa52371..71e2bde94 100644 --- a/src/commands/ping.ts +++ b/src/commands/ping.ts @@ -3,7 +3,7 @@ import { CommandRegistry } from '../events/interactionCreate/index.js'; export const pingCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, handlesInteraction: true, diff --git a/src/commands/playerAchievements.ts b/src/commands/playerAchievements.ts index fcd9c9a75..a0a6d41d9 100644 --- a/src/commands/playerAchievements.ts +++ b/src/commands/playerAchievements.ts @@ -18,7 +18,7 @@ type SortBy = 'name' | 'count'; export const playerAchievementsCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/playerInfo.ts b/src/commands/playerInfo.ts index 67ddcf1fa..d33e2f06a 100644 --- a/src/commands/playerInfo.ts +++ b/src/commands/playerInfo.ts @@ -12,7 +12,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const playerInfoCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/searchClans.ts b/src/commands/searchClans.ts index 18bdc8f00..64980acde 100644 --- a/src/commands/searchClans.ts +++ b/src/commands/searchClans.ts @@ -11,7 +11,7 @@ import { ClanList } from '../types/clanList.js'; export const searchClansCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/searchPlayers.ts b/src/commands/searchPlayers.ts index 870342c7a..4db2f37e4 100644 --- a/src/commands/searchPlayers.ts +++ b/src/commands/searchPlayers.ts @@ -12,7 +12,7 @@ import { AccountList } from '../types/accountList.js'; export const searchPlayersCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/searchTanks.ts b/src/commands/searchTanks.ts index 0d58bae86..ac859b7d1 100644 --- a/src/commands/searchTanks.ts +++ b/src/commands/searchTanks.ts @@ -8,7 +8,7 @@ import { CommandRegistry } from '../events/interactionCreate/index.js'; export const searchTanksCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index 9a8e4e59f..7860be991 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const statsCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: addStatTypeSubCommandGroups( diff --git a/src/commands/statsFull.tsx b/src/commands/statsFull.tsx index 180cc59f6..397218604 100644 --- a/src/commands/statsFull.tsx +++ b/src/commands/statsFull.tsx @@ -19,7 +19,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const statsFullCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: addStatTypeSubCommandGroups( diff --git a/src/commands/today.tsx b/src/commands/today.tsx index 613014928..d2a166afd 100644 --- a/src/commands/today.tsx +++ b/src/commands/today.tsx @@ -14,7 +14,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const todayCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/verify.ts b/src/commands/verify.ts index 0dc4aa4a5..c3cfb4b59 100644 --- a/src/commands/verify.ts +++ b/src/commands/verify.ts @@ -14,7 +14,7 @@ import { PlayerClanData } from '../types/playerClanData.js'; export const verifyCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/routes/stats.tsx b/src/routes/stats.tsx index 43216240d..71cd12053 100644 --- a/src/routes/stats.tsx +++ b/src/routes/stats.tsx @@ -6,7 +6,7 @@ import { RouteRegistry } from '../server.js'; export const statsRoute: RouteRegistry = { route: '/stats/:type/:period', inProduction: true, - inDevelopment: true, + inDevelopment: false, async handler(req) { const type = req.params.type as StatType; From 2bf5eb78bec175c17e518b8c28ffd478fe703167 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sat, 8 Jul 2023 19:47:21 +0000 Subject: [PATCH 03/26] feat: optimized tankopedia information --- src/components/Tanks/components/Item.tsx | 4 ++-- src/core/blitz/tankopedia.ts | 27 ++++++++++-------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/components/Tanks/components/Item.tsx b/src/components/Tanks/components/Item.tsx index 181379f18..b37b49a68 100644 --- a/src/components/Tanks/components/Item.tsx +++ b/src/components/Tanks/components/Item.tsx @@ -1,8 +1,8 @@ -import { TANK_ICONS, TankType } from '../../../core/blitz/tankopedia.js'; +import { TANK_ICONS } from '../../../core/blitz/tankopedia.js'; export interface ItemProps { icon?: string; - type?: TankType; + type?: string; name: string; } diff --git a/src/core/blitz/tankopedia.ts b/src/core/blitz/tankopedia.ts index 4452a611d..54174548c 100644 --- a/src/core/blitz/tankopedia.ts +++ b/src/core/blitz/tankopedia.ts @@ -1,15 +1,13 @@ -export type TankType = 'AT-SPG' | 'lightTank' | 'mediumTank' | 'heavyTank'; +import { WARGAMING_APPLICATION_ID } from '../node/arguments.js'; +import getWargamingResponse from './getWargamingResponse.js'; export interface TankopediaEntry { - name: string; - nation: string; - is_premium: boolean; - tier: number; - cost: { price_credit: number; price_gold: number }; - images: { preview: string; normal: string }; tank_id: number; - type: TankType; - description: string; + name: string; + tier: number; + type: string; + is_premium: boolean; + images: { preview: string; normal: string }; } export interface Tankopedia { @@ -17,12 +15,9 @@ export interface Tankopedia { } console.log('Caching tankopedia...'); -export const tankopedia = fetch('https://www.blitzstars.com/bs-tankopedia.json') - .then((response) => response.json()) - .then((wrapperTankopedia) => { - console.log('Tankopedia cached'); - return (wrapperTankopedia as { data: Tankopedia }).data; - }); +export const tankopedia = getWargamingResponse( + `https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${WARGAMING_APPLICATION_ID}&fields=name,tier,images,tank_id,type,is_premium`, +); const entries = new Promise(async (resolve) => { resolve(Object.entries(await tankopedia).map(([, entry]) => entry)); }); @@ -33,7 +28,7 @@ export const TANK_NAMES = new Promise(async (resolve) => { resolve((await entries).map(({ name }) => name)); }); -export const TANK_ICONS: Record = { +export const TANK_ICONS: Record = { 'AT-SPG': 'https://i.imgur.com/BIHSEH0.png', lightTank: 'https://i.imgur.com/CSNha5V.png', mediumTank: 'https://i.imgur.com/wvf3ltm.png', From cf20ae38d456e3f53a76802b48afddd68ced74bb Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sun, 9 Jul 2023 00:47:03 +0000 Subject: [PATCH 04/26] feat: updated /ownedtanks to new design --- src/commands/ownedTanks.tsx | 37 ++++++++++----- src/components/Tanks/components/Column.tsx | 20 ++++++++ src/components/Tanks/components/Item.tsx | 54 ++++++++++++++++------ src/components/Tanks/components/Root.tsx | 5 +- src/components/Tanks/index.ts | 1 + src/core/blitz/tankopedia.ts | 7 +++ src/stitches.config.ts | 3 +- 7 files changed, 96 insertions(+), 31 deletions(-) create mode 100644 src/components/Tanks/components/Column.tsx diff --git a/src/commands/ownedTanks.tsx b/src/commands/ownedTanks.tsx index 752ba3d56..370e3165f 100644 --- a/src/commands/ownedTanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -90,7 +90,6 @@ export const ownedTanksCommand: CommandRegistry = { `https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`, ); const leftColumnSize = Math.ceil(tanks.length / 2); - const rightColumnSize = tanks.length - leftColumnSize; const leftColumn = tanks.slice(0, leftColumnSize); const rightColumn = tanks.slice(leftColumnSize); @@ -114,16 +113,32 @@ export const ownedTanksCommand: CommandRegistry = { {tanks.length > 0 && ( - {await Promise.all( - tanks.map(async (tank) => ( - - )), - )} + + {await Promise.all( + leftColumn.map(async (tank) => ( + + )), + )} + + + {await Promise.all( + rightColumn.map(async (tank) => ( + + )), + )} + )} diff --git a/src/components/Tanks/components/Column.tsx b/src/components/Tanks/components/Column.tsx new file mode 100644 index 000000000..cd163ed27 --- /dev/null +++ b/src/components/Tanks/components/Column.tsx @@ -0,0 +1,20 @@ +import { ReactNode } from 'react'; + +export interface RootProps { + children: ReactNode; +} + +export function Column({ children }: RootProps) { + return ( +
+ {children} +
+ ); +} diff --git a/src/components/Tanks/components/Item.tsx b/src/components/Tanks/components/Item.tsx index b37b49a68..239dd4cab 100644 --- a/src/components/Tanks/components/Item.tsx +++ b/src/components/Tanks/components/Item.tsx @@ -1,38 +1,62 @@ -import { TANK_ICONS } from '../../../core/blitz/tankopedia.js'; +import { + TANK_ICONS, + TANK_ICONS_PREMIUM, +} from '../../../core/blitz/tankopedia.js'; +import { theme, themeAmber } from '../../../stitches.config.js'; export interface ItemProps { - icon?: string; + image?: string; type?: string; name: string; + isPremium?: boolean; } -export function Item({ icon, type, name }: ItemProps) { +export function Item({ image, type, name, isPremium }: ItemProps) { return (
- {icon && } - -
+
{type && ( - + )} - {name}
+ + {image && }
); } diff --git a/src/components/Tanks/components/Root.tsx b/src/components/Tanks/components/Root.tsx index 1a23e18ea..9d47b099f 100644 --- a/src/components/Tanks/components/Root.tsx +++ b/src/components/Tanks/components/Root.tsx @@ -9,10 +9,7 @@ export function Root({ children }: RootProps) {
{children} diff --git a/src/components/Tanks/index.ts b/src/components/Tanks/index.ts index 9ac57386e..4f3bf3609 100644 --- a/src/components/Tanks/index.ts +++ b/src/components/Tanks/index.ts @@ -1,2 +1,3 @@ +export * from './components/Column.js'; export * from './components/Item.js'; export * from './components/Root.js'; diff --git a/src/core/blitz/tankopedia.ts b/src/core/blitz/tankopedia.ts index 54174548c..7401a2db0 100644 --- a/src/core/blitz/tankopedia.ts +++ b/src/core/blitz/tankopedia.ts @@ -35,6 +35,13 @@ export const TANK_ICONS: Record = { heavyTank: 'https://i.imgur.com/ECeqlZa.png', }; +export const TANK_ICONS_PREMIUM: Record = { + 'AT-SPG': 'https://i.imgur.com/TCu3EdR.png', + lightTank: 'https://i.imgur.com/zdkpTRb.png', + mediumTank: 'https://i.imgur.com/3z7eHX6.png', + heavyTank: 'https://i.imgur.com/P3vbmyA.png', +}; + export type Tier = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10; export const TIER_ROMAN_NUMERALS: Record = { diff --git a/src/stitches.config.ts b/src/stitches.config.ts index c7f27bdff..c6190584b 100644 --- a/src/stitches.config.ts +++ b/src/stitches.config.ts @@ -1,4 +1,4 @@ -import { slate, slateDark } from '@radix-ui/colors'; +import { amberDark, slate, slateDark } from '@radix-ui/colors'; import { createBorderStyles, createColors } from 'bepaint'; // this isn't really a stitches config, but the object is compliant @@ -7,3 +7,4 @@ export const theme = { borderStyles: createBorderStyles(slateDark), }; export const themeLight = { colors: createColors(slate) }; +export const themeAmber = { colors: createColors(amberDark) }; From a0f15fc1c4c454ff8b5a39203ddb204b092f1de8 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sun, 9 Jul 2023 00:51:53 +0000 Subject: [PATCH 05/26] fix: revert back to blitz stars tankopedia for missing tanks --- src/core/blitz/tankopedia.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/core/blitz/tankopedia.ts b/src/core/blitz/tankopedia.ts index 7401a2db0..8e6789be0 100644 --- a/src/core/blitz/tankopedia.ts +++ b/src/core/blitz/tankopedia.ts @@ -1,13 +1,13 @@ -import { WARGAMING_APPLICATION_ID } from '../node/arguments.js'; -import getWargamingResponse from './getWargamingResponse.js'; - export interface TankopediaEntry { - tank_id: number; name: string; - tier: number; - type: string; + nation: string; is_premium: boolean; + tier: number; + cost: { price_credit: number; price_gold: number }; images: { preview: string; normal: string }; + tank_id: number; + type: string; + description: string; } export interface Tankopedia { @@ -15,9 +15,12 @@ export interface Tankopedia { } console.log('Caching tankopedia...'); -export const tankopedia = getWargamingResponse( - `https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${WARGAMING_APPLICATION_ID}&fields=name,tier,images,tank_id,type,is_premium`, -); +export const tankopedia = fetch('https://www.blitzstars.com/bs-tankopedia.json') + .then((response) => response.json()) + .then((wrapperTankopedia) => { + console.log('Tankopedia cached'); + return (wrapperTankopedia as { data: Tankopedia }).data; + }); const entries = new Promise(async (resolve) => { resolve(Object.entries(await tankopedia).map(([, entry]) => entry)); }); From 18e5405c540341aff8b20888c62d42e0c318a83e Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sun, 9 Jul 2023 00:52:13 +0000 Subject: [PATCH 06/26] fix: duplicate named interface export --- src/components/Tanks/components/Column.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Tanks/components/Column.tsx b/src/components/Tanks/components/Column.tsx index cd163ed27..7215c6186 100644 --- a/src/components/Tanks/components/Column.tsx +++ b/src/components/Tanks/components/Column.tsx @@ -1,10 +1,10 @@ import { ReactNode } from 'react'; -export interface RootProps { +export interface ColumnProps { children: ReactNode; } -export function Column({ children }: RootProps) { +export function Column({ children }: ColumnProps) { return (
Date: Sun, 9 Jul 2023 00:54:19 +0000 Subject: [PATCH 07/26] fix: normal image instead of preview --- src/commands/ownedTanks.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/ownedTanks.tsx b/src/commands/ownedTanks.tsx index 370e3165f..c0f0fe2c2 100644 --- a/src/commands/ownedTanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -120,7 +120,7 @@ export const ownedTanksCommand: CommandRegistry = { key={tank.tank_id} name={await resolveTankName(tank.tank_id)} type={tank.type} - image={tank.images?.preview} + image={tank.images?.normal} isPremium={tank.is_premium} /> )), @@ -133,7 +133,7 @@ export const ownedTanksCommand: CommandRegistry = { key={tank.tank_id} name={await resolveTankName(tank.tank_id)} type={tank.type} - image={tank.images?.preview} + image={tank.images?.normal} isPremium={tank.is_premium} /> )), From f64e72c312db80241fff07f89d8c2f723de76b93 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sun, 9 Jul 2023 01:02:30 +0000 Subject: [PATCH 08/26] feat: renamed statsfull to fullstats --- .vscode/settings.json | 1 + src/commands/evolution.tsx | 2 +- src/commands/{statsFull.tsx => fullStats.tsx} | 10 +++++----- src/commands/ownedTanks.tsx | 2 +- src/commands/stats.tsx | 2 +- src/events/interactionCreate/index.ts | 4 ++-- src/renderers/evolution.tsx | 2 +- src/renderers/{statsfull.tsx => fullStats.tsx} | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) rename src/commands/{statsFull.tsx => fullStats.tsx} (92%) rename src/renderers/{statsfull.tsx => fullStats.tsx} (98%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 86108f64d..847ba49b0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "cleandist", "customperiod", "Everytime", + "fullstats", "fuzzysort", "kranvagn", "outfile", diff --git a/src/commands/evolution.tsx b/src/commands/evolution.tsx index e9f2253f2..d2b7d59d1 100644 --- a/src/commands/evolution.tsx +++ b/src/commands/evolution.tsx @@ -15,7 +15,7 @@ import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.j import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; import { CommandRegistry } from '../events/interactionCreate/index.js'; import evolution from '../renderers/evolution.js'; -import { StatType } from '../renderers/statsfull.js'; +import { StatType } from '../renderers/fullStats.js'; import { AccountInfo } from '../types/accountInfo.js'; export const evolutionCommand: CommandRegistry = { diff --git a/src/commands/statsFull.tsx b/src/commands/fullStats.tsx similarity index 92% rename from src/commands/statsFull.tsx rename to src/commands/fullStats.tsx index 397218604..4b158a124 100644 --- a/src/commands/statsFull.tsx +++ b/src/commands/fullStats.tsx @@ -14,17 +14,17 @@ import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js' import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; import { CommandRegistry } from '../events/interactionCreate/index.js'; -import statsfull, { StatType } from '../renderers/statsfull.js'; +import fullStats, { StatType } from '../renderers/fullStats.js'; import { AccountInfo } from '../types/accountInfo.js'; -export const statsFullCommand: CommandRegistry = { +export const fullStatsCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, command: addStatTypeSubCommandGroups( new SlashCommandBuilder() - .setName('statsfull') + .setName('fullstats') .setDescription('Full in-game statistics'), ), @@ -52,7 +52,7 @@ export const statsFullCommand: CommandRegistry = { )[player.id]; return [ - await statsfull(commandGroup, period, player, tankId), + await fullStats(commandGroup, period, player, tankId), primaryButton(path, 'Refresh'), // linkButton(`${CYCLIC_API}/${path}`, 'Embed'), linkButton( @@ -74,7 +74,7 @@ export const statsFullCommand: CommandRegistry = { const period = resolvePeriodFromButton(interaction); const player = await resolvePlayerFromButton(interaction); - return await statsfull( + return await fullStats( commandGroup, period, player, diff --git a/src/commands/ownedTanks.tsx b/src/commands/ownedTanks.tsx index c0f0fe2c2..75dd86f5b 100644 --- a/src/commands/ownedTanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -44,7 +44,7 @@ const COMP_TANKS = [ export const ownedTanksCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index 7860be991..0ae09fd0e 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -14,8 +14,8 @@ import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js' import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; import { CommandRegistry } from '../events/interactionCreate/index.js'; +import { StatType } from '../renderers/fullStats.js'; import stats from '../renderers/stats.js'; -import { StatType } from '../renderers/statsfull.js'; import { AccountInfo } from '../types/accountInfo.js'; export const statsCommand: CommandRegistry = { diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 49b3ec1e7..3a5ee2cf2 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -26,7 +26,7 @@ import { searchClansCommand } from '../../commands/searchClans.js'; import { searchPlayersCommand } from '../../commands/searchPlayers.js'; import { searchTanksCommand } from '../../commands/searchTanks.js'; import { statsCommand } from '../../commands/stats.js'; -import { statsFullCommand } from '../../commands/statsFull.js'; +import { fullStatsCommand } from '../../commands/fullStats.js'; import { todayCommand } from '../../commands/today.js'; import { verifyCommand } from '../../commands/verify.js'; import { DISCORD_TOKEN } from '../../core/node/arguments.js'; @@ -82,7 +82,7 @@ export const commands: Record = ( searchClansCommand, searchPlayersCommand, searchTanksCommand, - statsFullCommand, + fullStatsCommand, todayCommand, verifyCommand, pingCommand, diff --git a/src/renderers/evolution.tsx b/src/renderers/evolution.tsx index 26dec06bd..2e3cafdc5 100644 --- a/src/renderers/evolution.tsx +++ b/src/renderers/evolution.tsx @@ -15,7 +15,7 @@ import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; import { AccountInfo } from '../types/accountInfo.js'; import { Histories } from '../types/histories.js'; import { PlayerClanData } from '../types/playerClanData.js'; -import { StatType } from './statsfull.js'; +import { StatType } from './fullStats.js'; export default async function evolution( type: Type, diff --git a/src/renderers/statsfull.tsx b/src/renderers/fullStats.tsx similarity index 98% rename from src/renderers/statsfull.tsx rename to src/renderers/fullStats.tsx index cf2180786..9c40c557e 100644 --- a/src/renderers/statsfull.tsx +++ b/src/renderers/fullStats.tsx @@ -25,7 +25,7 @@ import { PossiblyPromise } from '../types/possiblyPromise.js'; export type StatType = 'player' | 'tank'; -export default async function statsfull( +export default async function fullStats( type: Type, { start, end, statsName }: ResolvedPeriod, { server, id }: ResolvedPlayer, From f985cbf70b710e6064f4acd30289da973faee30b Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sun, 9 Jul 2023 01:12:02 +0000 Subject: [PATCH 09/26] feat: updated evolution from figma --- src/commands/evolution.tsx | 2 +- src/components/Graph/components/Margin.tsx | 2 +- src/components/Graph/components/Root.tsx | 19 +++++++++++++++++-- src/renderers/evolution.tsx | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/commands/evolution.tsx b/src/commands/evolution.tsx index d2b7d59d1..4eef95ccc 100644 --- a/src/commands/evolution.tsx +++ b/src/commands/evolution.tsx @@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const evolutionCommand: CommandRegistry = { inProduction: true, - inDevelopment: false, + inDevelopment: true, inPublic: true, command: addStatTypeSubCommandGroups( diff --git a/src/components/Graph/components/Margin.tsx b/src/components/Graph/components/Margin.tsx index 144a7904a..6a47082c9 100644 --- a/src/components/Graph/components/Margin.tsx +++ b/src/components/Graph/components/Margin.tsx @@ -37,7 +37,7 @@ export function Margin({ key={index} style={{ fontSize: 16, - color: theme.colors.textLowContrast, + color: theme.colors.textHighContrast, }} > {`${( diff --git a/src/components/Graph/components/Root.tsx b/src/components/Graph/components/Root.tsx index 5bc56b5db..ebadd058c 100644 --- a/src/components/Graph/components/Root.tsx +++ b/src/components/Graph/components/Root.tsx @@ -20,6 +20,7 @@ export interface RootProps { separations?: number; xMinLabel: string; xMaxLabel: string; + xTitle: string; } export function Root({ @@ -29,6 +30,7 @@ export function Root({ separations = 5, xMinLabel, xMaxLabel, + xTitle, }: RootProps) { return (
@@ -39,10 +41,10 @@ export function Root({ justifyContent: 'space-between', }} > - + {xMinLabel} - + {xMaxLabel}
@@ -88,6 +90,19 @@ export function Root({ orientation={MarginOrientation.Horizontal} /> )} + +
+ + {xTitle} + +
); } diff --git a/src/renderers/evolution.tsx b/src/renderers/evolution.tsx index 2e3cafdc5..e54417630 100644 --- a/src/renderers/evolution.tsx +++ b/src/renderers/evolution.tsx @@ -96,6 +96,7 @@ export default async function evolution( {/* goofy ahh bug forces me to call them as functions */} {plot.length > 0 && ( Date: Sun, 9 Jul 2023 17:37:44 +0000 Subject: [PATCH 10/26] feat: updated /today with figma --- src/commands/evolution.tsx | 2 +- src/commands/today.tsx | 2 +- src/components/Breakdown/components/Root.tsx | 2 +- src/components/Breakdown/components/Row.tsx | 46 ++++++++++--------- .../Breakdown/components/RowDiscriminator.tsx | 9 +++- .../Breakdown/components/RowStat.tsx | 19 ++++---- src/renderers/today.tsx | 9 ++-- 7 files changed, 48 insertions(+), 41 deletions(-) diff --git a/src/commands/evolution.tsx b/src/commands/evolution.tsx index 4eef95ccc..d2b7d59d1 100644 --- a/src/commands/evolution.tsx +++ b/src/commands/evolution.tsx @@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const evolutionCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: addStatTypeSubCommandGroups( diff --git a/src/commands/today.tsx b/src/commands/today.tsx index d2a166afd..613014928 100644 --- a/src/commands/today.tsx +++ b/src/commands/today.tsx @@ -14,7 +14,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const todayCommand: CommandRegistry = { inProduction: true, - inDevelopment: false, + inDevelopment: true, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/components/Breakdown/components/Root.tsx b/src/components/Breakdown/components/Root.tsx index e5d06bea7..9f40d82f9 100644 --- a/src/components/Breakdown/components/Root.tsx +++ b/src/components/Breakdown/components/Root.tsx @@ -6,7 +6,7 @@ export interface RootProps { export function Root({ children }: RootProps) { return ( -
+
{children}
); diff --git a/src/components/Breakdown/components/Row.tsx b/src/components/Breakdown/components/Row.tsx index f5e6c8786..31c904724 100644 --- a/src/components/Breakdown/components/Row.tsx +++ b/src/components/Breakdown/components/Row.tsx @@ -1,4 +1,5 @@ import getWN8Percentile from '../../../core/blitz/getWN8Percentile.js'; +import { theme } from '../../../stitches.config.js'; import { RowDiscriminator } from './RowDiscriminator.js'; import { RowStat } from './RowStat.js'; @@ -10,14 +11,16 @@ export interface RowProps { careerWN8?: number; damage: number; careerDamage: number; - survival: number; - careerSurvival: number; battles: number; careerBattles: number; icon?: string; + minimized: boolean; + isListing: boolean; } export function Row({ + isListing, + minimized, name, winrate, careerWinrate, @@ -25,44 +28,45 @@ export function Row({ careerWN8, damage, careerDamage, - survival, - careerSurvival, battles, careerBattles, icon, }: RowProps) { return ( -
- +
+ -
); diff --git a/src/components/Breakdown/components/RowDiscriminator.tsx b/src/components/Breakdown/components/RowDiscriminator.tsx index b4c9c8f2a..d70e6fa26 100644 --- a/src/components/Breakdown/components/RowDiscriminator.tsx +++ b/src/components/Breakdown/components/RowDiscriminator.tsx @@ -3,9 +3,14 @@ import { theme } from '../../../stitches.config.js'; export interface RowDiscriminatorProps { name: string; icon?: string; + minimized: boolean; } -export function RowDiscriminator({ name, icon }: RowDiscriminatorProps) { +export function RowDiscriminator({ + name, + icon, + minimized, +}: RowDiscriminatorProps) { return (
- {icon && ( + {!minimized && icon && ( - - {career} - -
{value}
- - {name} - + {!minimized && ( + + {name} + + )}
); } diff --git a/src/renderers/today.tsx b/src/renderers/today.tsx index 5b3369714..e36dbbce6 100644 --- a/src/renderers/today.tsx +++ b/src/renderers/today.tsx @@ -20,6 +20,7 @@ import { AccountInfo, AllStats } from '../types/accountInfo.js'; import { PlayerClanData } from '../types/playerClanData.js'; import { PossiblyPromise } from '../types/possiblyPromise.js'; +// TODO: sort tanks by last played export default async function today({ server, id }: ResolvedPlayer) { const tankStatsOverTime = await getTankStatsDiffed( server, @@ -110,12 +111,14 @@ export default async function today({ server, id }: ResolvedPlayer) { ); const rows = await Promise.all( - tankStatsOverTimeEntries.map(async ([tankIdString, tankStats]) => { - const tankId = Number(tankIdString); + tankStatsOverTimeEntries.map(async ([tankIdString, tankStats], index) => { + const tankId = parseInt(tankIdString); const career = careerStats[tankId]; return ( 4} key={tankId} name={ tankId === 0 ? 'Total' : await resolveTankName(Number(tankIdString)) @@ -126,8 +129,6 @@ export default async function today({ server, id }: ResolvedPlayer) { careerWN8={isNaN(careerWN8s[tankId]) ? undefined : careerWN8s[tankId]} damage={tankStats.damage_dealt / tankStats.battles} careerDamage={career.damage_dealt / career.battles} - survival={tankStats.survived_battles / tankStats.battles} - careerSurvival={career.survived_battles / career.battles} battles={tankStats.battles} careerBattles={career.battles} icon={ From d8ac0b2ef60ad8e4047101e5029c81868c04fba6 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sun, 9 Jul 2023 17:49:11 +0000 Subject: [PATCH 11/26] feat: added order to getDiffedTankStats --- src/commands/eligible.ts | 10 +++---- src/core/blitz/sumStats.ts | 2 +- ...nkStatsDiffed.ts => getDiffedTankStats.ts} | 28 +++++++++++++----- src/core/blitzstars/getPlayerHistories.ts | 2 +- src/core/blitzstars/getTankHistories.ts | 2 +- src/core/blitzstars/playerAverage.ts | 2 +- src/renderers/fullStats.tsx | 10 +++---- src/renderers/stats.tsx | 10 +++---- src/renderers/today.tsx | 29 ++++++++----------- 9 files changed, 51 insertions(+), 44 deletions(-) rename src/core/blitzstars/{getTankStatsDiffed.ts => getDiffedTankStats.ts} (80%) diff --git a/src/commands/eligible.ts b/src/commands/eligible.ts index 2df78fe04..fa1364c2b 100644 --- a/src/commands/eligible.ts +++ b/src/commands/eligible.ts @@ -3,9 +3,9 @@ import calculateWN8 from '../core/blitz/calculateWN8.js'; import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; import sumStats from '../core/blitz/sumStats.js'; import { tankopedia } from '../core/blitz/tankopedia.js'; +import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats.js'; import getPeriodNow from '../core/blitzstars/getPeriodNow.js'; import getPeriodStart from '../core/blitzstars/getPeriodStart.js'; -import getTankStatsDiffed from '../core/blitzstars/getTankStatsDiffed.js'; import { tankAverages } from '../core/blitzstars/tankAverages.js'; import addUsernameChoices from '../core/discord/addUsernameChoices.js'; import embedNegative from '../core/discord/embedNegative.js'; @@ -59,13 +59,13 @@ export const eligibleCommand: CommandRegistry = { let body = ''; if (clan === 'SKLLD') { - const tankStatsOverTime = await getTankStatsDiffed( + const { diffed } = await getDiffedTankStats( server, id, getPeriodStart('30'), getPeriodNow(), ); - const entries = Object.entries(tankStatsOverTime); + const entries = Object.entries(diffed); const stats = sumStats(entries.map(([, stats]) => stats)); const averageTier = (await entries.reduce>( @@ -116,7 +116,7 @@ export const eligibleCommand: CommandRegistry = { const tankId = parseInt(tankIdString); if ((await tankopedia)[tankId]?.tier === 10) { - const tankStats = tankStatsOverTime[tankId]; + const tankStats = diffed[tankId]; return (await accumulator) + tankStats.damage_dealt; } else return accumulator; }, @@ -127,7 +127,7 @@ export const eligibleCommand: CommandRegistry = { const tankId = parseInt(tankIdString); if ((await tankopedia)[tankId]?.tier === 10) { - const tankStats = tankStatsOverTime[tankId]; + const tankStats = diffed[tankId]; return (await accumulator) + tankStats.battles; } else return accumulator; }, diff --git a/src/core/blitz/sumStats.ts b/src/core/blitz/sumStats.ts index 10b2095a0..31bf53d6f 100644 --- a/src/core/blitz/sumStats.ts +++ b/src/core/blitz/sumStats.ts @@ -1,5 +1,5 @@ import { AllStats } from '../../types/accountInfo.js'; -import { emptyAllStats } from '../blitzstars/getTankStatsDiffed.js'; +import { emptyAllStats } from '../blitzstars/getDiffedTankStats.js'; export default function sumStats(allStatsCollection: AllStats[]) { return allStatsCollection.reduce((accumulated, current) => { diff --git a/src/core/blitzstars/getTankStatsDiffed.ts b/src/core/blitzstars/getDiffedTankStats.ts similarity index 80% rename from src/core/blitzstars/getTankStatsDiffed.ts rename to src/core/blitzstars/getDiffedTankStats.ts index 513f7f21c..208b816ad 100644 --- a/src/core/blitzstars/getTankStatsDiffed.ts +++ b/src/core/blitzstars/getDiffedTankStats.ts @@ -34,7 +34,7 @@ export const emptyTankHistoryNode: TankHistoryRaw = { all: emptyAllStats, }; -export default async function getTankStatsDiffed( +export default async function getDiffedTankStats( server: BlitzServer, id: number, start: number, @@ -46,26 +46,27 @@ export default async function getTankStatsDiffed( // sort them even though most won't be used const tankSortedHistory: Record = {}; - const tankIds: number[] = []; + const tanks: number[] = []; history.forEach((node) => { if (!tankSortedHistory[node.tank_id]) { tankSortedHistory[node.tank_id] = [node]; - tankIds.push(node.tank_id); + tanks.push(node.tank_id); } else { tankSortedHistory[node.tank_id].push(node); } }); // find the ones played within the range - const tankIdsInRange = tankIds.filter((tankId) => + const inRangeTanks = tanks.filter((tankId) => tankSortedHistory[tankId].some( (node) => node.last_battle_time > start && node.last_battle_time < end, ), ); + const playedTanks: number[] = []; // fetch history node right before "start" and right before "end" - const tanksBeforeAndAfter: Record = {}; - tankIdsInRange.forEach((tankId) => { + const diffed: Record = {}; + inRangeTanks.forEach((tankId) => { const sortedHistory = tankSortedHistory[tankId]; const previousIndex = sortedHistory.findIndex((node) => node.last_battle_time > start) - 1; @@ -81,7 +82,7 @@ export default async function getTankStatsDiffed( // check if there was a change in battles as games in ratings do update last_battle_time if (diff((a) => a.battles) > 0) { - tanksBeforeAndAfter[tankId] = { + diffed[tankId] = { battles: diff((a) => a.battles), capture_points: diff((a) => a.capture_points), damage_dealt: diff((a) => a.damage_dealt), @@ -100,8 +101,19 @@ export default async function getTankStatsDiffed( wins: diff((a) => a.wins), xp: diff((a) => a.xp), }; + + playedTanks.push(tankId); } }); - return tanksBeforeAndAfter; + const order = playedTanks.sort((a, b) => { + const aHistories = tankSortedHistory[a]; + const bHistories = tankSortedHistory[b]; + const aLatest = aHistories[aHistories.length - 1]; + const bLatest = bHistories[bHistories.length - 1]; + + return bLatest.last_battle_time - aLatest.last_battle_time; + }); + + return { diffed, order }; } diff --git a/src/core/blitzstars/getPlayerHistories.ts b/src/core/blitzstars/getPlayerHistories.ts index 72e6aa852..fcbf625be 100644 --- a/src/core/blitzstars/getPlayerHistories.ts +++ b/src/core/blitzstars/getPlayerHistories.ts @@ -8,7 +8,7 @@ import { } from '../../types/histories.js'; import getWargamingResponse from '../blitz/getWargamingResponse.js'; import { WARGAMING_APPLICATION_ID } from '../node/arguments.js'; -import { emptyAllStats } from './getTankStatsDiffed.js'; +import { emptyAllStats } from './getDiffedTankStats.js'; export interface PlayerHistoryRaw { clan: { clan_id: number; name: string; tag: string }; diff --git a/src/core/blitzstars/getTankHistories.ts b/src/core/blitzstars/getTankHistories.ts index 4e69e198c..b2a7aa713 100644 --- a/src/core/blitzstars/getTankHistories.ts +++ b/src/core/blitzstars/getTankHistories.ts @@ -6,7 +6,7 @@ import { getHistoriesDefaultOptions, } from '../../types/histories.js'; import getTankStats from '../blitz/getTankStats.js'; -import { emptyAllStats } from './getTankStatsDiffed.js'; +import { emptyAllStats } from './getDiffedTankStats.js'; export interface TankHistory extends History { tank_id: number; diff --git a/src/core/blitzstars/playerAverage.ts b/src/core/blitzstars/playerAverage.ts index f2206d83c..4f79f77af 100644 --- a/src/core/blitzstars/playerAverage.ts +++ b/src/core/blitzstars/playerAverage.ts @@ -1,5 +1,5 @@ import sumStats from '../blitz/sumStats.js'; -import { emptyAllStats } from './getTankStatsDiffed.js'; +import { emptyAllStats } from './getDiffedTankStats.js'; import { tankAverages } from './tankAverages.js'; console.log('Calculating player average...'); diff --git a/src/renderers/fullStats.tsx b/src/renderers/fullStats.tsx index 9c40c557e..698d8794a 100644 --- a/src/renderers/fullStats.tsx +++ b/src/renderers/fullStats.tsx @@ -10,7 +10,7 @@ import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; import resolveTankName from '../core/blitz/resolveTankName.js'; import sumStats from '../core/blitz/sumStats.js'; import { Tier, tankopedia } from '../core/blitz/tankopedia.js'; -import getTankStatsDiffed from '../core/blitzstars/getTankStatsDiffed.js'; +import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats.js'; import { tankAverages } from '../core/blitzstars/tankAverages.js'; import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand.js'; import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand.js'; @@ -50,13 +50,13 @@ export default async function fullStats( image = (await tankopedia)[tankId!]?.images.normal; } - const tankStats = await getTankStatsDiffed(server, id, start, end); + const { diffed } = await getDiffedTankStats(server, id, start, end); let stats: AllStats; let supplementaryStats: SupplementaryStats; let tierWeights: TierWeightsRecord; if (type === 'player') { - const entries = Object.entries(tankStats); + const entries = Object.entries(diffed); stats = sumStats(entries.map(([, stats]) => stats)); const battlesOfTanksWithAverages = await entries.reduce< PossiblyPromise @@ -124,10 +124,10 @@ export default async function fullStats( {}, ); } else { - stats = tankStats[tankId!]; + stats = diffed[tankId!]; supplementaryStats = { - WN8: calculateWN8((await tankAverages)[tankId!].all, tankStats[tankId!]), + WN8: calculateWN8((await tankAverages)[tankId!].all, diffed[tankId!]), tier: (await tankopedia)[tankId!]?.tier, }; } diff --git a/src/renderers/stats.tsx b/src/renderers/stats.tsx index 6027869e1..314bf7077 100644 --- a/src/renderers/stats.tsx +++ b/src/renderers/stats.tsx @@ -10,7 +10,7 @@ import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; import resolveTankName from '../core/blitz/resolveTankName.js'; import sumStats from '../core/blitz/sumStats.js'; import { Tier, tankopedia } from '../core/blitz/tankopedia.js'; -import getTankStatsDiffed from '../core/blitzstars/getTankStatsDiffed.js'; +import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats.js'; import { tankAverages } from '../core/blitzstars/tankAverages.js'; import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand.js'; import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand.js'; @@ -52,13 +52,13 @@ export default async function stats( image = (await tankopedia)[tankId!]?.images.normal; } - const tankStats = await getTankStatsDiffed(server, id, start, end); + const { diffed } = await getDiffedTankStats(server, id, start, end); let stats: AllStats | undefined; let supplementaryStats: SupplementaryStats; let tierWeights: TierWeightsRecord; if (type === 'player') { - const entries = Object.entries(tankStats); + const entries = Object.entries(diffed); stats = sumStats(entries.map(([, stats]) => stats)); const battlesOfTanksWithAverages = await entries.reduce< PossiblyPromise @@ -126,11 +126,11 @@ export default async function stats( {}, ); } else { - stats = tankStats[tankId!]; + stats = diffed[tankId!]; supplementaryStats = { WN8: stats - ? calculateWN8((await tankAverages)[tankId!].all, tankStats[tankId!]) + ? calculateWN8((await tankAverages)[tankId!].all, diffed[tankId!]) : undefined, tier: (await tankopedia)[tankId!]?.tier, }; diff --git a/src/renderers/today.tsx b/src/renderers/today.tsx index e36dbbce6..62fd19504 100644 --- a/src/renderers/today.tsx +++ b/src/renderers/today.tsx @@ -10,8 +10,8 @@ import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; import resolveTankName from '../core/blitz/resolveTankName.js'; import sumStats from '../core/blitz/sumStats.js'; import { tankopedia } from '../core/blitz/tankopedia.js'; +import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats.js'; import getPeriodNow from '../core/blitzstars/getPeriodNow.js'; -import getTankStatsDiffed from '../core/blitzstars/getTankStatsDiffed.js'; import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo.js'; import { tankAverages } from '../core/blitzstars/tankAverages.js'; import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand.js'; @@ -22,7 +22,7 @@ import { PossiblyPromise } from '../types/possiblyPromise.js'; // TODO: sort tanks by last played export default async function today({ server, id }: ResolvedPlayer) { - const tankStatsOverTime = await getTankStatsDiffed( + const { diffed, order } = await getDiffedTankStats( server, id, getTimeDaysAgo(0), @@ -40,7 +40,7 @@ export default async function today({ server, id }: ResolvedPlayer) { }; const allStatsToAccumulate: AllStats[] = []; - Object.entries(tankStatsOverTime).forEach(([, tankStats]) => { + Object.entries(diffed).forEach(([, tankStats]) => { allStatsToAccumulate.push(tankStats); }); Object.entries(careerTankStatsRaw).forEach(([, tankStats]) => { @@ -49,11 +49,11 @@ export default async function today({ server, id }: ResolvedPlayer) { const accumulatedStats = sumStats(allStatsToAccumulate); - if (Object.keys(tankStatsOverTime).length > 0) { - tankStatsOverTime[0] = accumulatedStats; + if (Object.keys(diffed).length > 0) { + diffed[0] = accumulatedStats; } - const tankStatsOverTimeEntries = Object.entries(tankStatsOverTime); + const tankStatsOverTimeEntries = Object.entries(diffed); const todayWN8s = await tankStatsOverTimeEntries.reduce< PossiblyPromise> >(async (accumulator, [tankIdString, tankStats]) => { @@ -86,12 +86,12 @@ export default async function today({ server, id }: ResolvedPlayer) { todayWN8s[0] = todayWN8sEntries.reduce( (accumulator, [tankIdString, wn8]) => - accumulator + wn8 * tankStatsOverTime[Number(tankIdString)].battles, + accumulator + wn8 * diffed[Number(tankIdString)].battles, 0, ) / todayWN8sEntries.reduce( (accumulator, [tankIdString]) => - accumulator + tankStatsOverTime[Number(tankIdString)].battles, + accumulator + diffed[Number(tankIdString)].battles, 0, ); careerWN8s[0] = @@ -111,8 +111,8 @@ export default async function today({ server, id }: ResolvedPlayer) { ); const rows = await Promise.all( - tankStatsOverTimeEntries.map(async ([tankIdString, tankStats], index) => { - const tankId = parseInt(tankIdString); + [0, ...order].map(async (tankId, index) => { + const tankStats = diffed[tankId]; const career = careerStats[tankId]; return ( @@ -120,9 +120,7 @@ export default async function today({ server, id }: ResolvedPlayer) { isListing={tankId !== 0} minimized={index > 4} key={tankId} - name={ - tankId === 0 ? 'Total' : await resolveTankName(Number(tankIdString)) - } + name={tankId === 0 ? 'Total' : await resolveTankName(tankId)} winrate={tankStats.wins / tankStats.battles} careerWinrate={career.wins / career.battles} WN8={isNaN(todayWN8s[tankId]) ? undefined : todayWN8s[tankId]} @@ -132,10 +130,7 @@ export default async function today({ server, id }: ResolvedPlayer) { battles={tankStats.battles} careerBattles={career.battles} icon={ - tankId === 0 - ? undefined - : (await tankopedia)[tankIdString as unknown as number]?.images - .normal + tankId === 0 ? undefined : (await tankopedia)[tankId]?.images.normal } /> ); From dd0644e09ff9ce7ebeb1b15e29c14cc93dc0b2e5 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Mon, 10 Jul 2023 01:23:35 +0000 Subject: [PATCH 12/26] fix: no tanks played now does not display a total --- src/renderers/today.tsx | 55 ++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/renderers/today.tsx b/src/renderers/today.tsx index 62fd19504..1f264cfc6 100644 --- a/src/renderers/today.tsx +++ b/src/renderers/today.tsx @@ -20,12 +20,11 @@ import { AccountInfo, AllStats } from '../types/accountInfo.js'; import { PlayerClanData } from '../types/playerClanData.js'; import { PossiblyPromise } from '../types/possiblyPromise.js'; -// TODO: sort tanks by last played export default async function today({ server, id }: ResolvedPlayer) { const { diffed, order } = await getDiffedTankStats( server, id, - getTimeDaysAgo(0), + getTimeDaysAgo(server, 1), getPeriodNow(), ); const accountInfo = await getWargamingResponse( @@ -111,30 +110,36 @@ export default async function today({ server, id }: ResolvedPlayer) { ); const rows = await Promise.all( - [0, ...order].map(async (tankId, index) => { - const tankStats = diffed[tankId]; - const career = careerStats[tankId]; + [...(order.length === 0 ? [] : [0]), ...order].map( + async (tankId, index) => { + const tankStats = diffed[tankId]; + const career = careerStats[tankId]; - return ( - 4} - key={tankId} - name={tankId === 0 ? 'Total' : await resolveTankName(tankId)} - winrate={tankStats.wins / tankStats.battles} - careerWinrate={career.wins / career.battles} - WN8={isNaN(todayWN8s[tankId]) ? undefined : todayWN8s[tankId]} - careerWN8={isNaN(careerWN8s[tankId]) ? undefined : careerWN8s[tankId]} - damage={tankStats.damage_dealt / tankStats.battles} - careerDamage={career.damage_dealt / career.battles} - battles={tankStats.battles} - careerBattles={career.battles} - icon={ - tankId === 0 ? undefined : (await tankopedia)[tankId]?.images.normal - } - /> - ); - }), + return ( + 4} + key={tankId} + name={tankId === 0 ? 'Total' : await resolveTankName(tankId)} + winrate={tankStats.wins / tankStats.battles} + careerWinrate={career.wins / career.battles} + WN8={isNaN(todayWN8s[tankId]) ? undefined : todayWN8s[tankId]} + careerWN8={ + isNaN(careerWN8s[tankId]) ? undefined : careerWN8s[tankId] + } + damage={tankStats.damage_dealt / tankStats.battles} + careerDamage={career.damage_dealt / career.battles} + battles={tankStats.battles} + careerBattles={career.battles} + icon={ + tankId === 0 + ? undefined + : (await tankopedia)[tankId]?.images.normal + } + /> + ); + }, + ), ); return ( From 405f544774a23ede434342750d44e23ba411df56 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Mon, 10 Jul 2023 01:23:49 +0000 Subject: [PATCH 13/26] fix: time zone compliant commands --- src/commands/eligible.ts | 4 ++-- src/commands/evolution.tsx | 4 ++-- src/commands/fullStats.tsx | 4 ++-- src/commands/stats.tsx | 6 +++--- src/core/blitzstars/getPeriodStart.ts | 10 ++++++--- src/core/blitzstars/getTimeDaysAgo.ts | 22 +++++++++++++------- src/core/discord/resolvePeriodFromButton.ts | 4 +++- src/core/discord/resolvePeriodFromCommand.ts | 8 ++++--- src/core/express/resolvePeriodFromRequest.ts | 8 +++++-- src/core/express/resolvePeriodFromURL.ts | 12 +++++++---- src/routes/stats.tsx | 2 +- 11 files changed, 54 insertions(+), 30 deletions(-) diff --git a/src/commands/eligible.ts b/src/commands/eligible.ts index fa1364c2b..db3c77e00 100644 --- a/src/commands/eligible.ts +++ b/src/commands/eligible.ts @@ -5,7 +5,7 @@ import sumStats from '../core/blitz/sumStats.js'; import { tankopedia } from '../core/blitz/tankopedia.js'; import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats.js'; import getPeriodNow from '../core/blitzstars/getPeriodNow.js'; -import getPeriodStart from '../core/blitzstars/getPeriodStart.js'; +import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo.js'; import { tankAverages } from '../core/blitzstars/tankAverages.js'; import addUsernameChoices from '../core/discord/addUsernameChoices.js'; import embedNegative from '../core/discord/embedNegative.js'; @@ -62,7 +62,7 @@ export const eligibleCommand: CommandRegistry = { const { diffed } = await getDiffedTankStats( server, id, - getPeriodStart('30'), + getTimeDaysAgo(server, 30), getPeriodNow(), ); const entries = Object.entries(diffed); diff --git a/src/commands/evolution.tsx b/src/commands/evolution.tsx index d2b7d59d1..555f1dd1f 100644 --- a/src/commands/evolution.tsx +++ b/src/commands/evolution.tsx @@ -34,7 +34,7 @@ export const evolutionCommand: CommandRegistry = { true, ) as StatType; const player = await resolvePlayerFromCommand(interaction); - const period = resolvePeriodFromCommand(interaction); + const period = resolvePeriodFromCommand(player.server, interaction); const tankIdRaw = interaction.options.getString('tank')!; const tankId = commandGroup === 'tank' ? await resolveTankId(tankIdRaw) : null; @@ -74,8 +74,8 @@ export const evolutionCommand: CommandRegistry = { const url = new URL(`${CYCLIC_API}/${interaction.customId}`); const path = url.pathname.split('/').filter(Boolean); const commandGroup = path[1] as StatType; - const period = resolvePeriodFromButton(interaction); const player = await resolvePlayerFromButton(interaction); + const period = resolvePeriodFromButton(player.server, interaction); return await evolution( commandGroup, diff --git a/src/commands/fullStats.tsx b/src/commands/fullStats.tsx index 4b158a124..4991a4bb6 100644 --- a/src/commands/fullStats.tsx +++ b/src/commands/fullStats.tsx @@ -33,7 +33,7 @@ export const fullStatsCommand: CommandRegistry = { true, ) as StatType; const player = await resolvePlayerFromCommand(interaction); - const period = resolvePeriodFromCommand(interaction); + const period = resolvePeriodFromCommand(player.server, interaction); const tankIdRaw = interaction.options.getString('tank')!; const tankId = commandGroup === 'tank' ? await resolveTankId(tankIdRaw) : null; @@ -71,8 +71,8 @@ export const fullStatsCommand: CommandRegistry = { const url = new URL(`${CYCLIC_API}/${interaction.customId}`); const path = url.pathname.split('/').filter(Boolean); const commandGroup = path[1] as StatType; - const period = resolvePeriodFromButton(interaction); const player = await resolvePlayerFromButton(interaction); + const period = resolvePeriodFromButton(player.server, interaction); return await fullStats( commandGroup, diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index 0ae09fd0e..24b1583bb 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const statsCommand: CommandRegistry = { inProduction: true, - inDevelopment: false, + inDevelopment: true, inPublic: true, command: addStatTypeSubCommandGroups( @@ -34,7 +34,7 @@ export const statsCommand: CommandRegistry = { true, ) as StatType; const player = await resolvePlayerFromCommand(interaction); - const period = resolvePeriodFromCommand(interaction); + const period = resolvePeriodFromCommand(player.server, interaction); const tankIdRaw = interaction.options.getString('tank')!; const tankId = commandGroup === 'tank' ? await resolveTankId(tankIdRaw) : null; @@ -72,8 +72,8 @@ export const statsCommand: CommandRegistry = { const url = new URL(`${CYCLIC_API}/${interaction.customId}`); const path = url.pathname.split('/').filter(Boolean); const commandGroup = path[1] as StatType; - const period = resolvePeriodFromButton(interaction); const player = await resolvePlayerFromButton(interaction); + const period = resolvePeriodFromButton(player.server, interaction); return await stats( commandGroup, diff --git a/src/core/blitzstars/getPeriodStart.ts b/src/core/blitzstars/getPeriodStart.ts index ec955af34..d1d820428 100644 --- a/src/core/blitzstars/getPeriodStart.ts +++ b/src/core/blitzstars/getPeriodStart.ts @@ -1,12 +1,16 @@ +import { BlitzServer } from '../../constants/servers.js'; import { Period } from '../discord/addPeriodSubCommands.js'; import getTimeDaysAgo from './getTimeDaysAgo.js'; -export default function getPeriodStart(period: Exclude) { +export default function getPeriodStart( + server: BlitzServer, + period: Exclude, +) { if (period === 'career') { return -Infinity; } else if (period === 'today') { - return getTimeDaysAgo(0); + return getTimeDaysAgo(server, 1); } else { - return getTimeDaysAgo(parseInt(period)); + return getTimeDaysAgo(server, parseInt(period)); } } diff --git a/src/core/blitzstars/getTimeDaysAgo.ts b/src/core/blitzstars/getTimeDaysAgo.ts index 86a3512ea..357bca538 100644 --- a/src/core/blitzstars/getTimeDaysAgo.ts +++ b/src/core/blitzstars/getTimeDaysAgo.ts @@ -1,12 +1,20 @@ -export default function getTimeDaysAgo(daysAgo: number) { +import { BlitzServer } from '../../constants/servers.js'; + +export const TIME_ZONE_MAPPINGS: Record = { + com: -5, // Central North American Time + eu: +1, // Central European Time + asia: +7, // Central Asia Standard Time +}; + +export default function getTimeDaysAgo(server: BlitzServer, daysAgo: number) { const now = new Date(); - now.setHours(5, 0, 0, 0); + if (daysAgo === 0) now.getTime() / 1000; - // if it's after 5:00 AM today, subtract one day - if (now.getTime() > Date.now()) now.setDate(now.getDate() - 1); + const time = new Date(); - // subtract the period number of days from now - now.setDate(now.getDate() - daysAgo); + time.setUTCHours(-TIME_ZONE_MAPPINGS[server], 0, 0, 0); + if (time > now) time.setUTCDate(time.getUTCDate() - 1); + time.setUTCDate(time.getUTCDate() - daysAgo + 1); - return now.getTime() / 1000; + return time.getTime() / 1000; } diff --git a/src/core/discord/resolvePeriodFromButton.ts b/src/core/discord/resolvePeriodFromButton.ts index cda3c11ca..823780c75 100644 --- a/src/core/discord/resolvePeriodFromButton.ts +++ b/src/core/discord/resolvePeriodFromButton.ts @@ -1,9 +1,11 @@ import { ButtonInteraction, CacheType } from 'discord.js'; import { CYCLIC_API } from '../../constants/cyclic.js'; +import { BlitzServer } from '../../constants/servers.js'; import resolvePeriodFromURL from '../express/resolvePeriodFromURL.js'; export default function resolvePeriodFromButton( + server: BlitzServer, interaction: ButtonInteraction, ) { - return resolvePeriodFromURL(`${CYCLIC_API}/${interaction.customId}`); + return resolvePeriodFromURL(server, `${CYCLIC_API}/${interaction.customId}`); } diff --git a/src/core/discord/resolvePeriodFromCommand.ts b/src/core/discord/resolvePeriodFromCommand.ts index 6c5a6bfe5..c3d8816d6 100644 --- a/src/core/discord/resolvePeriodFromCommand.ts +++ b/src/core/discord/resolvePeriodFromCommand.ts @@ -1,4 +1,5 @@ import { CacheType, ChatInputCommandInteraction } from 'discord.js'; +import { BlitzServer } from '../../constants/servers.js'; import getPeriodNow from '../blitzstars/getPeriodNow.js'; import getPeriodStart from '../blitzstars/getPeriodStart.js'; import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo.js'; @@ -30,6 +31,7 @@ export interface ResolvedPeriod { } export default function resolvePeriodFromCommand( + server: BlitzServer, interaction: ChatInputCommandInteraction, ) { let statsName: string; @@ -46,12 +48,12 @@ export default function resolvePeriodFromCommand( statsName = `${startMin} to ${endMax} days' statistics`; evolutionName = `${startMin} to ${endMax} days' evolution`; - start = getTimeDaysAgo(startMin); - end = getTimeDaysAgo(endMax); + start = getTimeDaysAgo(server, startMin); + end = getTimeDaysAgo(server, endMax); } else { statsName = PERIOD_NAMES[period]; evolutionName = EVOLUTION_PERIOD_NAMES[period]; - start = getPeriodStart(period); + start = getPeriodStart(server, period); end = getPeriodNow(); } diff --git a/src/core/express/resolvePeriodFromRequest.ts b/src/core/express/resolvePeriodFromRequest.ts index 8695d79a0..2350d09e0 100644 --- a/src/core/express/resolvePeriodFromRequest.ts +++ b/src/core/express/resolvePeriodFromRequest.ts @@ -1,7 +1,11 @@ import { Request } from 'express'; import { CYCLIC_API } from '../../constants/cyclic.js'; +import { BlitzServer } from '../../constants/servers.js'; import resolvePeriodFromURL from './resolvePeriodFromURL.js'; -export default function resolvePeriodFromRequest(request: Request) { - return resolvePeriodFromURL(`${CYCLIC_API}${request.path}`); +export default function resolvePeriodFromRequest( + server: BlitzServer, + request: Request, +) { + return resolvePeriodFromURL(server, `${CYCLIC_API}${request.path}`); } diff --git a/src/core/express/resolvePeriodFromURL.ts b/src/core/express/resolvePeriodFromURL.ts index 2799f2f39..e490a15aa 100644 --- a/src/core/express/resolvePeriodFromURL.ts +++ b/src/core/express/resolvePeriodFromURL.ts @@ -1,3 +1,4 @@ +import { BlitzServer } from '../../constants/servers.js'; import getPeriodNow from '../blitzstars/getPeriodNow.js'; import getPeriodStart from '../blitzstars/getPeriodStart.js'; import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo.js'; @@ -8,7 +9,10 @@ import { ResolvedPeriod, } from '../discord/resolvePeriodFromCommand.js'; -export default function resolvePeriodFromURL(urlString: string) { +export default function resolvePeriodFromURL( + server: BlitzServer, + urlString: string, +) { let statsName: string; let evolutionName: string; let start: number; @@ -25,12 +29,12 @@ export default function resolvePeriodFromURL(urlString: string) { statsName = `${startMin} to ${endMax} days' statistics`; evolutionName = `${startMin} to ${endMax} days' evolution`; - start = getTimeDaysAgo(startMin); - end = getTimeDaysAgo(endMax); + start = getTimeDaysAgo(server, startMin); + end = getTimeDaysAgo(server, endMax); } else { statsName = PERIOD_NAMES[period]; evolutionName = EVOLUTION_PERIOD_NAMES[period]; - start = getPeriodStart(period); + start = getPeriodStart(server, period); end = getPeriodNow(); } diff --git a/src/routes/stats.tsx b/src/routes/stats.tsx index 71cd12053..f67840232 100644 --- a/src/routes/stats.tsx +++ b/src/routes/stats.tsx @@ -10,8 +10,8 @@ export const statsRoute: RouteRegistry = { async handler(req) { const type = req.params.type as StatType; - const period = resolvePeriodFromRequest(req); const player = resolvePlayerFromRequest(req); + const period = resolvePeriodFromRequest(player.server, req); return await stats( type, From 8f6388b42b3e87cda60f00f04835987385377e96 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Mon, 10 Jul 2023 01:27:13 +0000 Subject: [PATCH 14/26] fix: time resets at 5:00 am --- src/core/blitzstars/getTimeDaysAgo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/blitzstars/getTimeDaysAgo.ts b/src/core/blitzstars/getTimeDaysAgo.ts index 357bca538..4264810ea 100644 --- a/src/core/blitzstars/getTimeDaysAgo.ts +++ b/src/core/blitzstars/getTimeDaysAgo.ts @@ -12,7 +12,7 @@ export default function getTimeDaysAgo(server: BlitzServer, daysAgo: number) { const time = new Date(); - time.setUTCHours(-TIME_ZONE_MAPPINGS[server], 0, 0, 0); + time.setUTCHours(-TIME_ZONE_MAPPINGS[server] + 5, 0, 0, 0); if (time > now) time.setUTCDate(time.getUTCDate() - 1); time.setUTCDate(time.getUTCDate() - daysAgo + 1); From 438feefa8366fc005bb0e30586f88a43dc49e33e Mon Sep 17 00:00:00 2001 From: tresabhi Date: Mon, 10 Jul 2023 01:44:05 +0000 Subject: [PATCH 15/26] feat: today embeds --- src/commands/today.tsx | 3 ++- src/components/Breakdown/components/Row.tsx | 10 ++++++++-- src/components/Wrapper.tsx | 8 ++++++-- src/renderers/stats.tsx | 2 +- src/renderers/today.tsx | 12 ++++++++++-- src/routes/today.tsx | 15 +++++++++++++++ src/server.ts | 3 ++- src/stitches.config.ts | 5 ++++- 8 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 src/routes/today.tsx diff --git a/src/commands/today.tsx b/src/commands/today.tsx index 613014928..7c10612cd 100644 --- a/src/commands/today.tsx +++ b/src/commands/today.tsx @@ -1,4 +1,5 @@ import { SlashCommandBuilder } from 'discord.js'; +import { CYCLIC_API } from '../constants/cyclic.js'; import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; import addUsernameChoices from '../core/discord/addUsernameChoices.js'; import autocompleteUsername from '../core/discord/autocompleteUsername.js'; @@ -34,7 +35,7 @@ export const todayCommand: CommandRegistry = { return [ await today(player), primaryButton(path, 'Refresh'), - // linkButton(`${CYCLIC_API}/${path}`, 'Embed'), + linkButton(`${CYCLIC_API}/${path}`, 'Embed'), linkButton( `https://www.blitzstars.com/player/${player.server}/${nickname}`, 'BlitzStars', diff --git a/src/components/Breakdown/components/Row.tsx b/src/components/Breakdown/components/Row.tsx index 31c904724..ef39602cd 100644 --- a/src/components/Breakdown/components/Row.tsx +++ b/src/components/Breakdown/components/Row.tsx @@ -1,5 +1,5 @@ import getWN8Percentile from '../../../core/blitz/getWN8Percentile.js'; -import { theme } from '../../../stitches.config.js'; +import { theme, themeTransparent } from '../../../stitches.config.js'; import { RowDiscriminator } from './RowDiscriminator.js'; import { RowStat } from './RowStat.js'; @@ -16,6 +16,7 @@ export interface RowProps { icon?: string; minimized: boolean; isListing: boolean; + naked?: boolean; } export function Row({ @@ -31,6 +32,7 @@ export function Row({ battles, careerBattles, icon, + naked, }: RowProps) { return (
{children} diff --git a/src/renderers/stats.tsx b/src/renderers/stats.tsx index 314bf7077..5756da28a 100644 --- a/src/renderers/stats.tsx +++ b/src/renderers/stats.tsx @@ -156,7 +156,7 @@ export default async function stats( ); return naked ? ( - overview + {overview} ) : ( 4} key={tankId} @@ -142,7 +146,11 @@ export default async function today({ server, id }: ResolvedPlayer) { ), ); - return ( + return naked ? ( + + {rows.slice(1)} + + ) : ( ; @@ -20,7 +21,7 @@ export interface RouteRegistry const app = express(); -([statsRoute] as RouteRegistry[]).forEach((registry) => { +([statsRoute, todayRoute] as RouteRegistry[]).forEach((registry) => { if (!(isDev() ? registry.inDevelopment : registry.inProduction)) return; app.get(registry.route, async (req, res) => { diff --git a/src/stitches.config.ts b/src/stitches.config.ts index c6190584b..673116268 100644 --- a/src/stitches.config.ts +++ b/src/stitches.config.ts @@ -1,4 +1,4 @@ -import { amberDark, slate, slateDark } from '@radix-ui/colors'; +import { amberDark, slate, slateDark, slateDarkA } from '@radix-ui/colors'; import { createBorderStyles, createColors } from 'bepaint'; // this isn't really a stitches config, but the object is compliant @@ -6,5 +6,8 @@ export const theme = { colors: createColors(slateDark), borderStyles: createBorderStyles(slateDark), }; +export const themeTransparent = { + colors: createColors(slateDarkA), +}; export const themeLight = { colors: createColors(slate) }; export const themeAmber = { colors: createColors(amberDark) }; From 297f2f6580c917f6a0abef183ee1e17bb27f889e Mon Sep 17 00:00:00 2001 From: tresabhi Date: Mon, 10 Jul 2023 17:41:48 +0000 Subject: [PATCH 16/26] feat: added limits to /today --- src/commands/today.tsx | 14 ++++++++-- src/renderers/today.tsx | 59 ++++++++++++++++++++--------------------- src/routes/today.tsx | 6 ++++- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/commands/today.tsx b/src/commands/today.tsx index 7c10612cd..d3329380c 100644 --- a/src/commands/today.tsx +++ b/src/commands/today.tsx @@ -21,10 +21,20 @@ export const todayCommand: CommandRegistry = { command: new SlashCommandBuilder() .setName('today') .setDescription('A general daily breakdown of your performance') - .addStringOption(addUsernameChoices), + .addStringOption(addUsernameChoices) + .addIntegerOption((option) => + option + .setName('limit') + .setDescription( + 'The maximum number of tanks to display (default: Infinity)', + ) + .setRequired(false) + .setMinValue(1), + ), async handler(interaction) { const player = await resolvePlayerFromCommand(interaction); + const limit = interaction.options.getInteger('limit') ?? Infinity; const { nickname } = ( await getWargamingResponse( `https://api.wotblitz.${player.server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`, @@ -33,7 +43,7 @@ export const todayCommand: CommandRegistry = { const path = interactionToURL(interaction, player); return [ - await today(player), + await today(player, limit, false), primaryButton(path, 'Refresh'), linkButton(`${CYCLIC_API}/${path}`, 'Embed'), linkButton( diff --git a/src/renderers/today.tsx b/src/renderers/today.tsx index 93da5c594..9a0c96839 100644 --- a/src/renderers/today.tsx +++ b/src/renderers/today.tsx @@ -22,6 +22,7 @@ import { PossiblyPromise } from '../types/possiblyPromise.js'; export default async function today( { server, id }: ResolvedPlayer, + limit = Infinity, naked?: boolean, ) { const { diffed, order } = await getDiffedTankStats( @@ -113,37 +114,35 @@ export default async function today( ); const rows = await Promise.all( - [...(order.length === 0 ? [] : [0]), ...order].map( - async (tankId, index) => { - const tankStats = diffed[tankId]; - const career = careerStats[tankId]; + [ + // this code unreadable on god will forget tomorrow no cap + ...(order.length === 0 ? [] : [0]), + ...(isFinite(limit) ? order.slice(0, limit) : order), + ].map(async (tankId, index) => { + const tankStats = diffed[tankId]; + const career = careerStats[tankId]; - return ( - 4} - key={tankId} - name={tankId === 0 ? 'Total' : await resolveTankName(tankId)} - winrate={tankStats.wins / tankStats.battles} - careerWinrate={career.wins / career.battles} - WN8={isNaN(todayWN8s[tankId]) ? undefined : todayWN8s[tankId]} - careerWN8={ - isNaN(careerWN8s[tankId]) ? undefined : careerWN8s[tankId] - } - damage={tankStats.damage_dealt / tankStats.battles} - careerDamage={career.damage_dealt / career.battles} - battles={tankStats.battles} - careerBattles={career.battles} - icon={ - tankId === 0 - ? undefined - : (await tankopedia)[tankId]?.images.normal - } - /> - ); - }, - ), + return ( + 4} + key={tankId} + name={tankId === 0 ? 'Total' : await resolveTankName(tankId)} + winrate={tankStats.wins / tankStats.battles} + careerWinrate={career.wins / career.battles} + WN8={isNaN(todayWN8s[tankId]) ? undefined : todayWN8s[tankId]} + careerWN8={isNaN(careerWN8s[tankId]) ? undefined : careerWN8s[tankId]} + damage={tankStats.damage_dealt / tankStats.battles} + careerDamage={career.damage_dealt / career.battles} + battles={tankStats.battles} + careerBattles={career.battles} + icon={ + tankId === 0 ? undefined : (await tankopedia)[tankId]?.images.normal + } + /> + ); + }), ); return naked ? ( diff --git a/src/routes/today.tsx b/src/routes/today.tsx index 30b8a1c0a..b4bf67298 100644 --- a/src/routes/today.tsx +++ b/src/routes/today.tsx @@ -10,6 +10,10 @@ export const todayRoute: RouteRegistry = { async handler(req) { const player = resolvePlayerFromRequest(req); - return await today(player, true); + return await today( + player, + req.query.limit ? parseInt(req.query.limit as string) : undefined, + true, + ); }, }; From 0833375562c0a563ba670a4d27ff2b17473687a4 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Mon, 10 Jul 2023 17:42:29 +0000 Subject: [PATCH 17/26] feat: reset stats at midnight --- src/core/blitzstars/getTimeDaysAgo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/blitzstars/getTimeDaysAgo.ts b/src/core/blitzstars/getTimeDaysAgo.ts index 4264810ea..357bca538 100644 --- a/src/core/blitzstars/getTimeDaysAgo.ts +++ b/src/core/blitzstars/getTimeDaysAgo.ts @@ -12,7 +12,7 @@ export default function getTimeDaysAgo(server: BlitzServer, daysAgo: number) { const time = new Date(); - time.setUTCHours(-TIME_ZONE_MAPPINGS[server] + 5, 0, 0, 0); + time.setUTCHours(-TIME_ZONE_MAPPINGS[server], 0, 0, 0); if (time > now) time.setUTCDate(time.getUTCDate() - 1); time.setUTCDate(time.getUTCDate() - daysAgo + 1); From 80ffff322ce79223aca514a1c2fcc32e30020d65 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Mon, 10 Jul 2023 17:44:56 +0000 Subject: [PATCH 18/26] feat: merge themes --- src/components/Breakdown/components/Row.tsx | 6 +++--- src/components/Tanks/components/Item.tsx | 6 +++--- src/components/TierWeights.tsx | 6 +++--- src/stitches.config.ts | 13 +++++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/components/Breakdown/components/Row.tsx b/src/components/Breakdown/components/Row.tsx index ef39602cd..27e8ab831 100644 --- a/src/components/Breakdown/components/Row.tsx +++ b/src/components/Breakdown/components/Row.tsx @@ -1,5 +1,5 @@ import getWN8Percentile from '../../../core/blitz/getWN8Percentile.js'; -import { theme, themeTransparent } from '../../../stitches.config.js'; +import { theme } from '../../../stitches.config.js'; import { RowDiscriminator } from './RowDiscriminator.js'; import { RowStat } from './RowStat.js'; @@ -41,10 +41,10 @@ export function Row({ borderRadius: 4, backgroundColor: isListing ? naked - ? themeTransparent.colors.componentInteractive + ? theme.colors.componentInteractive_transparent : theme.colors.componentInteractive : naked - ? themeTransparent.colors.appBackground2 + ? theme.colors.appBackground2_transparent : theme.colors.appBackground2, padding: 8, }} diff --git a/src/components/Tanks/components/Item.tsx b/src/components/Tanks/components/Item.tsx index 239dd4cab..c4a2f6fa3 100644 --- a/src/components/Tanks/components/Item.tsx +++ b/src/components/Tanks/components/Item.tsx @@ -2,7 +2,7 @@ import { TANK_ICONS, TANK_ICONS_PREMIUM, } from '../../../core/blitz/tankopedia.js'; -import { theme, themeAmber } from '../../../stitches.config.js'; +import { theme } from '../../../stitches.config.js'; export interface ItemProps { image?: string; @@ -23,7 +23,7 @@ export function Item({ image, type, name, isPremium }: ItemProps) { alignItems: 'center', borderRadius: 4, backgroundColor: isPremium - ? themeAmber.colors.componentInteractive + ? theme.colors.componentInteractive_amber : theme.colors.componentInteractive, }} > @@ -48,7 +48,7 @@ export function Item({ image, type, name, isPremium }: ItemProps) { fontSize: 16, whiteSpace: 'nowrap', color: isPremium - ? themeAmber.colors.textLowContrast + ? theme.colors.textLowContrast_amber : theme.colors.textHighContrast, }} > diff --git a/src/components/TierWeights.tsx b/src/components/TierWeights.tsx index 8923b027b..21421c11f 100644 --- a/src/components/TierWeights.tsx +++ b/src/components/TierWeights.tsx @@ -1,5 +1,5 @@ import { TIER_ROMAN_NUMERALS, Tier } from '../core/blitz/tankopedia.js'; -import { themeLight } from '../stitches.config.js'; +import { theme } from '../stitches.config.js'; export type TierWeightsRecord = Partial>; @@ -14,9 +14,9 @@ export default function TierWeights({ weights }: TierWeightsProps) {
Date: Mon, 10 Jul 2023 18:16:33 +0000 Subject: [PATCH 19/26] feat: added collector tanks to /ownedtanks --- src/commands/ownedTanks.tsx | 12 +++---- src/components/Tanks/components/Item.tsx | 44 ++++++++++++++++-------- src/core/blitz/getTreeType.ts | 11 ++++++ src/core/blitz/tankopedia.ts | 8 +++++ src/stitches.config.ts | 11 +++++- 5 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 src/core/blitz/getTreeType.ts diff --git a/src/commands/ownedTanks.tsx b/src/commands/ownedTanks.tsx index 75dd86f5b..d27980cde 100644 --- a/src/commands/ownedTanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -6,6 +6,7 @@ import TitleBar from '../components/TitleBar.js'; import Wrapper from '../components/Wrapper.js'; import { BLITZ_SERVERS } from '../constants/servers.js'; import getTankStats from '../core/blitz/getTankStats.js'; +import getTreeType from '../core/blitz/getTreeType.js'; import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; import resolveTankName from '../core/blitz/resolveTankName.js'; import { @@ -44,7 +45,7 @@ const COMP_TANKS = [ export const ownedTanksCommand: CommandRegistry = { inProduction: true, - inDevelopment: false, + inDevelopment: true, inPublic: true, command: new SlashCommandBuilder() @@ -95,7 +96,6 @@ export const ownedTanksCommand: CommandRegistry = { return ( - {/* TODO: integrate some of these into title bar */} )), )} @@ -132,9 +132,9 @@ export const ownedTanksCommand: CommandRegistry = { )), )} diff --git a/src/components/Tanks/components/Item.tsx b/src/components/Tanks/components/Item.tsx index c4a2f6fa3..e0458eeca 100644 --- a/src/components/Tanks/components/Item.tsx +++ b/src/components/Tanks/components/Item.tsx @@ -1,17 +1,36 @@ import { TANK_ICONS, + TANK_ICONS_COLLECTOR, TANK_ICONS_PREMIUM, } from '../../../core/blitz/tankopedia.js'; import { theme } from '../../../stitches.config.js'; -export interface ItemProps { - image?: string; - type?: string; - name: string; - isPremium?: boolean; +export enum TreeType { + TechTree, + Premium, + Collector, } -export function Item({ image, type, name, isPremium }: ItemProps) { +export interface ItemProps { + image?: string; + tankType?: string; + name: string; + treeType: TreeType; +} + +const TREE_TYPE_COLOR = { + [TreeType.TechTree]: '', + [TreeType.Premium]: '_amber', + [TreeType.Collector]: '_blue', +} as const; + +const TREE_TYPE_ICONS = { + [TreeType.TechTree]: TANK_ICONS, + [TreeType.Premium]: TANK_ICONS_PREMIUM, + [TreeType.Collector]: TANK_ICONS_COLLECTOR, +}; + +export function Item({ image, tankType, name, treeType }: ItemProps) { return (
- {type && ( + {tankType && ( )} @@ -47,9 +65,7 @@ export function Item({ image, type, name, isPremium }: ItemProps) { style={{ fontSize: 16, whiteSpace: 'nowrap', - color: isPremium - ? theme.colors.textLowContrast_amber - : theme.colors.textHighContrast, + color: theme.colors[`textLowContrast${TREE_TYPE_COLOR[treeType]}`], }} > {name} diff --git a/src/core/blitz/getTreeType.ts b/src/core/blitz/getTreeType.ts new file mode 100644 index 000000000..6bedbe83e --- /dev/null +++ b/src/core/blitz/getTreeType.ts @@ -0,0 +1,11 @@ +import { TreeType } from '../../components/Tanks/index.js'; +import { tankopedia } from './tankopedia.js'; + +export default async function getTreeType(id: number) { + const entry = (await tankopedia)[id]; + + if (entry?.is_collectible) return TreeType.Collector; + if (entry?.is_premium) return TreeType.Premium; + + return TreeType.TechTree; +} diff --git a/src/core/blitz/tankopedia.ts b/src/core/blitz/tankopedia.ts index 8e6789be0..557f3a4e6 100644 --- a/src/core/blitz/tankopedia.ts +++ b/src/core/blitz/tankopedia.ts @@ -2,6 +2,7 @@ export interface TankopediaEntry { name: string; nation: string; is_premium: boolean; + is_collectible: boolean; tier: number; cost: { price_credit: number; price_gold: number }; images: { preview: string; normal: string }; @@ -45,6 +46,13 @@ export const TANK_ICONS_PREMIUM: Record = { heavyTank: 'https://i.imgur.com/P3vbmyA.png', }; +export const TANK_ICONS_COLLECTOR: Record = { + 'AT-SPG': 'https://i.imgur.com/WTjeirB.png', + lightTank: 'https://i.imgur.com/EwhtKkU.png', + mediumTank: 'https://i.imgur.com/u8YDMBh.png', + heavyTank: 'https://i.imgur.com/8xRf3nc.png', +}; + export type Tier = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10; export const TIER_ROMAN_NUMERALS: Record = { diff --git a/src/stitches.config.ts b/src/stitches.config.ts index 374f36a03..b75ceefae 100644 --- a/src/stitches.config.ts +++ b/src/stitches.config.ts @@ -1,4 +1,10 @@ -import { amberDark, slate, slateDark, slateDarkA } from '@radix-ui/colors'; +import { + amberDark, + blueDark, + slate, + slateDark, + slateDarkA, +} from '@radix-ui/colors'; import { createBorderStyles, createColors } from 'bepaint'; // this isn't really a stitches config, but the object is compliant @@ -6,8 +12,11 @@ export const theme = { colors: { ...createColors(slateDark), ...createColors(slate, 'light'), + ...createColors(slateDarkA, 'transparent'), + ...createColors(amberDark, 'amber'), + ...createColors(blueDark, 'blue'), }, borderStyles: createBorderStyles(slateDark), From 463af106bef49dbcf040c7712d35684fb1f9e758 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Mon, 10 Jul 2023 19:14:16 +0000 Subject: [PATCH 20/26] feat: added more help commands --- docs/guide/about.md | 10 ++ docs/guide/embeds.md | 23 ++++ docs/guide/invite.md | 10 ++ src/commands/help.ts | 111 ++++++++++++++---- src/commands/ownedTanks.tsx | 2 +- src/commands/stats.tsx | 2 +- src/commands/today.tsx | 2 +- src/components/Breakdown/components/Row.tsx | 6 +- src/core/discord/embedInfo.ts | 7 +- .../discord/normalizeInteractionReturnable.ts | 4 +- src/events/interactionCreate/index.ts | 51 ++++---- src/routes/today.tsx | 2 +- src/stitches.config.ts | 10 +- 13 files changed, 174 insertions(+), 66 deletions(-) create mode 100644 docs/guide/about.md create mode 100644 docs/guide/embeds.md create mode 100644 docs/guide/invite.md diff --git a/docs/guide/about.md b/docs/guide/about.md new file mode 100644 index 000000000..40c3b25c3 --- /dev/null +++ b/docs/guide/about.md @@ -0,0 +1,10 @@ +# About + +Blitzkrieg is a multipurpose bot for anything and everything World of Tanks Blitz. + +- Track statistics +- Find inactive players in a clan +- Lookup owned tanks +- Create embeds for streams +- Track a player/tanks statistical evolution +- ...and a variety of other similar things diff --git a/docs/guide/embeds.md b/docs/guide/embeds.md new file mode 100644 index 000000000..b663d0bfc --- /dev/null +++ b/docs/guide/embeds.md @@ -0,0 +1,23 @@ +# Embeds + +Embeds are generated by a few commands as a URL that can be loaded in a browser/streaming software. + +## Creating Embeds + +1. Use a command of your liking (for example, `/stats`). +2. Customize the command however you like and the URL generated for the embed will match your needs. +3. Send the command and when the bot is "done thinking," an "Embed" button will appear below the bot's reply. + +## Using Embeds in Streaming Softwares + +1. Click on the "Embed" button. +2. Copy the URL from your browser. +3. Paste the URL into a Browser Source. +4. Set the refresh rate/FPS to something very low like `0.0167` (that's 1 frame every 60 seconds). + +## How Embeds Behave + +- They load like any normal website albeit with a significant delay. +- They auto refresh every `60s`. +- All embeds and images generated by Blitzkrieg have a width of `640px` but the height varies and must be found manually through trial and error. + - It's okay to have a Browser Source that has a height larger than needed as Blitzkrieg embeds are transparent. diff --git a/docs/guide/invite.md b/docs/guide/invite.md new file mode 100644 index 000000000..307d0fa89 --- /dev/null +++ b/docs/guide/invite.md @@ -0,0 +1,10 @@ +# Inviting the Bot + +It's quite simple really. Just follow the steps below: + +1. Join a Discord server that already has Blitzkrieg installed or [the official Discord Server](https://discord.gg/nDt7AjGJQH). +2. Click on the bot's profile. +3. Click the "Add to Server" button under the bot's name and ID. +4. Select what server you want it in and see what permissions you seem fit for the bot. + +Voila! You're ready to go. diff --git a/src/commands/help.ts b/src/commands/help.ts index 408fe78b7..32e280296 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -1,36 +1,105 @@ -import { SlashCommandBuilder } from 'discord.js'; -import discord from '../../discord.json' assert { type: 'json' }; -import { client } from '../bot.js'; +import { + SlashCommandBuilder, + SlashCommandSubcommandBuilder, + SlashCommandSubcommandGroupBuilder, +} from 'discord.js'; import embedInfo from '../core/discord/embedInfo.js'; import { + COMMANDS_RAW, CommandRegistry, - guildCommands, - publicCommands, } from '../events/interactionCreate/index.js'; +const RAW_PATH = `https://raw.githubusercontent.com/tresabhi/blitzkrieg/main/docs/`; +const DOCS: Record = { + permissions: 'guide/permissions', + embeds: 'guide/embeds', + about: 'guide/about', + invite: 'guide/invite', +}; + export const helpCommand: CommandRegistry = { inProduction: true, - inDevelopment: false, + inDevelopment: true, inPublic: true, command: new SlashCommandBuilder() .setName('help') - .setDescription('All the help you need about the bot'), + .setDescription('All the help you need about the bot') + .addSubcommand((option) => + option + .setName('commands') + .setDescription('List of all commands and their descriptions'), + ) + .addSubcommand((option) => + option + .setName('permissions') + .setDescription('The permissions needed for the bot to function'), + ) + .addSubcommand((option) => + option.setName('about').setDescription('About the bot'), + ) + .addSubcommand((option) => + option.setName('embeds').setDescription('How embeds work'), + ) + .addSubcommand((option) => + option.setName('invite').setDescription('How to invite the bot'), + ), handler(interaction) { - return embedInfo( - `${client.user?.username} help`, - `**About**\n${ - client.user?.username - } automates many mundane tasks and provide statistics in numerous flexible ways.\n\nMade by TresAbhi from the Skilled [SKLLD] clan.\nGitHub: https://github.com/tresabhi/blitzkrieg\nDiscord server: https://discord.gg/nDt7AjGJQH\nSkilled server: https://discord.gg/ZPvcEG7DS8\n\n**Commands**\n${(interaction.guildId === - discord.sklld_guild_id - ? [...guildCommands, ...publicCommands] - : publicCommands - ) - .map((command) => `**/${command.name}**: ${command.description}`) - .join( - '\n', - )}\n\n*I am a new bot; I may make mistakes and go offline unexpectedly from time to time.*`, - ); + const subcommand = interaction.options.getSubcommand(); + + if (subcommand === 'commands') { + return [ + `# Commands\n\nBlitzkrieg offers the following commands:`, + embedInfo( + '', + COMMANDS_RAW.filter( + (registry) => registry.inPublic && registry.inProduction, + ) + .map((registry) => { + const info = `- \`/${registry.command.name}\`: ${registry.command.description}`; + const subcommandGroups = registry.command.options.filter( + (option) => + option instanceof SlashCommandSubcommandGroupBuilder, + ) as SlashCommandSubcommandGroupBuilder[]; + const subcommands = registry.command.options.filter( + (option) => option instanceof SlashCommandSubcommandBuilder, + ) as SlashCommandSubcommandBuilder[]; + + const tree = + subcommandGroups.length > 0 + ? subcommandGroups + .map((subcommandGroup) => { + const info = ` - \`${subcommandGroup.name}\`: ${subcommandGroup.description}`; + const subcommands = subcommandGroup.options + .map( + (subcommand) => + ` - \`${subcommand.name}\`: ${subcommand.description}`, + ) + .join('\n'); + + return `${info}${ + subcommands ? `\n${subcommands}` : '' + }`; + }) + .join('\n') + : subcommands + .map( + (subcommand) => + ` - \`${subcommand.name}\`: ${subcommand.description}`, + ) + .join('\n'); + + return `${info}${tree ? `\n${tree}` : ''}`; + }) + .join('\n'), + ), + ]; + } + + const url = `${RAW_PATH}${DOCS[subcommand]}.md`; + const content = fetch(url).then((response) => response.text()); + + return content; }, }; diff --git a/src/commands/ownedTanks.tsx b/src/commands/ownedTanks.tsx index d27980cde..d02575688 100644 --- a/src/commands/ownedTanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -45,7 +45,7 @@ const COMP_TANKS = [ export const ownedTanksCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index 24b1583bb..d302a286e 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const statsCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: addStatTypeSubCommandGroups( diff --git a/src/commands/today.tsx b/src/commands/today.tsx index d3329380c..3b269819c 100644 --- a/src/commands/today.tsx +++ b/src/commands/today.tsx @@ -15,7 +15,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const todayCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/components/Breakdown/components/Row.tsx b/src/components/Breakdown/components/Row.tsx index 27e8ab831..e418f4b52 100644 --- a/src/components/Breakdown/components/Row.tsx +++ b/src/components/Breakdown/components/Row.tsx @@ -40,11 +40,7 @@ export function Row({ display: 'flex', borderRadius: 4, backgroundColor: isListing - ? naked - ? theme.colors.componentInteractive_transparent - : theme.colors.componentInteractive - : naked - ? theme.colors.appBackground2_transparent + ? theme.colors.componentInteractive : theme.colors.appBackground2, padding: 8, }} diff --git a/src/core/discord/embedInfo.ts b/src/core/discord/embedInfo.ts index 4c591e1f6..a188a1643 100644 --- a/src/core/discord/embedInfo.ts +++ b/src/core/discord/embedInfo.ts @@ -2,8 +2,11 @@ import { EmbedBuilder } from 'discord.js'; import { ACCENT_COLOR } from '../../constants/colors.js'; export default function embedInfo(title: string, description: string) { - return new EmbedBuilder() + const embed = new EmbedBuilder() .setColor(ACCENT_COLOR) - .setTitle(title) .setDescription(description); + + if (title) embed.setTitle(title); + + return embed; } diff --git a/src/core/discord/normalizeInteractionReturnable.ts b/src/core/discord/normalizeInteractionReturnable.ts index d935763a3..828812eb2 100644 --- a/src/core/discord/normalizeInteractionReturnable.ts +++ b/src/core/discord/normalizeInteractionReturnable.ts @@ -19,7 +19,9 @@ export default async function normalizeInteractionReturnable( await Promise.all( normalizedReturnable.map(async (item) => { - if (item instanceof EmbedBuilder) { + if (typeof item === 'string') { + reply.content = item; + } else if (item instanceof EmbedBuilder) { if (!reply.embeds) reply.embeds = []; reply.embeds.push(item); } else if (item instanceof ButtonBuilder) { diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 3a5ee2cf2..952155d16 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -16,6 +16,7 @@ import discord from '../../../discord.json' assert { type: 'json' }; import { debugCommand } from '../../commands/debug.js'; import { eligibleCommand } from '../../commands/eligible.js'; import { evolutionCommand } from '../../commands/evolution.js'; +import { fullStatsCommand } from '../../commands/fullStats.js'; import { helpCommand } from '../../commands/help.js'; import { inactiveCommand } from '../../commands/inactive.js'; import { ownedTanksCommand } from '../../commands/ownedTanks.js'; @@ -26,7 +27,6 @@ import { searchClansCommand } from '../../commands/searchClans.js'; import { searchPlayersCommand } from '../../commands/searchPlayers.js'; import { searchTanksCommand } from '../../commands/searchTanks.js'; import { statsCommand } from '../../commands/stats.js'; -import { fullStatsCommand } from '../../commands/fullStats.js'; import { todayCommand } from '../../commands/today.js'; import { verifyCommand } from '../../commands/verify.js'; import { DISCORD_TOKEN } from '../../core/node/arguments.js'; @@ -37,6 +37,7 @@ import handleButton from './handlers/button.js'; import handleChatInputCommand from './handlers/chatInputCommand.js'; export type InteractionRawReturnable = + | string | EmbedBuilder | ButtonBuilder | JSX.Element; @@ -70,29 +71,31 @@ export interface CommandRegistry const rest = new REST().setToken(DISCORD_TOKEN); -export const commands: Record = ( - [ - debugCommand, - eligibleCommand, - helpCommand, - inactiveCommand, - ownedTanksCommand, - playerAchievementsCommand, - playerInfoCommand, - searchClansCommand, - searchPlayersCommand, - searchTanksCommand, - fullStatsCommand, - todayCommand, - verifyCommand, - pingCommand, - evolutionCommand, - statsCommand, - ] as CommandRegistry[] -).reduce((accumulator, registry) => { - if (isDev()) registry.command.setDefaultMemberPermissions(0); - return { ...accumulator, [registry.command.name]: registry }; -}, {}); +export const COMMANDS_RAW: CommandRegistry[] = [ + debugCommand, + eligibleCommand, + helpCommand, + inactiveCommand, + ownedTanksCommand, + playerAchievementsCommand, + playerInfoCommand, + searchClansCommand, + searchPlayersCommand, + searchTanksCommand, + fullStatsCommand, + todayCommand, + verifyCommand, + pingCommand, + evolutionCommand, + statsCommand, +]; +export const commands: Record = COMMANDS_RAW.reduce( + (accumulator, registry) => { + if (isDev()) registry.command.setDefaultMemberPermissions(0); + return { ...accumulator, [registry.command.name]: registry }; + }, + {}, +); export const guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = []; diff --git a/src/routes/today.tsx b/src/routes/today.tsx index b4bf67298..257c79473 100644 --- a/src/routes/today.tsx +++ b/src/routes/today.tsx @@ -5,7 +5,7 @@ import { RouteRegistry } from '../server.js'; export const todayRoute: RouteRegistry = { route: '/today', inProduction: true, - inDevelopment: true, + inDevelopment: false, async handler(req) { const player = resolvePlayerFromRequest(req); diff --git a/src/stitches.config.ts b/src/stitches.config.ts index b75ceefae..30036ab13 100644 --- a/src/stitches.config.ts +++ b/src/stitches.config.ts @@ -1,10 +1,4 @@ -import { - amberDark, - blueDark, - slate, - slateDark, - slateDarkA, -} from '@radix-ui/colors'; +import { amberDark, blueDark, slate, slateDark } from '@radix-ui/colors'; import { createBorderStyles, createColors } from 'bepaint'; // this isn't really a stitches config, but the object is compliant @@ -13,8 +7,6 @@ export const theme = { ...createColors(slateDark), ...createColors(slate, 'light'), - ...createColors(slateDarkA, 'transparent'), - ...createColors(amberDark, 'amber'), ...createColors(blueDark, 'blue'), }, From 6c8f5ca478d3c46c0df740d0c1342463ab525d05 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Tue, 11 Jul 2023 18:44:32 +0000 Subject: [PATCH 21/26] feat: simplified commands help --- src/commands/help.ts | 61 +++++++------------------------------------- src/routes/today.tsx | 2 +- 2 files changed, 10 insertions(+), 53 deletions(-) diff --git a/src/commands/help.ts b/src/commands/help.ts index 32e280296..210a68980 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -1,9 +1,4 @@ -import { - SlashCommandBuilder, - SlashCommandSubcommandBuilder, - SlashCommandSubcommandGroupBuilder, -} from 'discord.js'; -import embedInfo from '../core/discord/embedInfo.js'; +import { SlashCommandBuilder } from 'discord.js'; import { COMMANDS_RAW, CommandRegistry, @@ -49,52 +44,14 @@ export const helpCommand: CommandRegistry = { const subcommand = interaction.options.getSubcommand(); if (subcommand === 'commands') { - return [ - `# Commands\n\nBlitzkrieg offers the following commands:`, - embedInfo( - '', - COMMANDS_RAW.filter( - (registry) => registry.inPublic && registry.inProduction, - ) - .map((registry) => { - const info = `- \`/${registry.command.name}\`: ${registry.command.description}`; - const subcommandGroups = registry.command.options.filter( - (option) => - option instanceof SlashCommandSubcommandGroupBuilder, - ) as SlashCommandSubcommandGroupBuilder[]; - const subcommands = registry.command.options.filter( - (option) => option instanceof SlashCommandSubcommandBuilder, - ) as SlashCommandSubcommandBuilder[]; - - const tree = - subcommandGroups.length > 0 - ? subcommandGroups - .map((subcommandGroup) => { - const info = ` - \`${subcommandGroup.name}\`: ${subcommandGroup.description}`; - const subcommands = subcommandGroup.options - .map( - (subcommand) => - ` - \`${subcommand.name}\`: ${subcommand.description}`, - ) - .join('\n'); - - return `${info}${ - subcommands ? `\n${subcommands}` : '' - }`; - }) - .join('\n') - : subcommands - .map( - (subcommand) => - ` - \`${subcommand.name}\`: ${subcommand.description}`, - ) - .join('\n'); - - return `${info}${tree ? `\n${tree}` : ''}`; - }) - .join('\n'), - ), - ]; + return `# Commands\n\nBlitzkrieg offers the following commands:\n\n${COMMANDS_RAW.filter( + (registry) => registry.inPublic && registry.inProduction, + ) + .map( + (registry) => + `- \`/${registry.command.name}\`: ${registry.command.description}`, + ) + .join('\n')}`; } const url = `${RAW_PATH}${DOCS[subcommand]}.md`; diff --git a/src/routes/today.tsx b/src/routes/today.tsx index 257c79473..b4bf67298 100644 --- a/src/routes/today.tsx +++ b/src/routes/today.tsx @@ -5,7 +5,7 @@ import { RouteRegistry } from '../server.js'; export const todayRoute: RouteRegistry = { route: '/today', inProduction: true, - inDevelopment: false, + inDevelopment: true, async handler(req) { const player = resolvePlayerFromRequest(req); From fedad8df3ed1e00ba4a9389541133823efa2504a Mon Sep 17 00:00:00 2001 From: tresabhi Date: Tue, 11 Jul 2023 19:00:10 +0000 Subject: [PATCH 22/26] feat: added timezone help --- docs/guide/timezones.md | 9 +++++++ src/commands/help.ts | 57 +++++++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 docs/guide/timezones.md diff --git a/docs/guide/timezones.md b/docs/guide/timezones.md new file mode 100644 index 000000000..3b344cc55 --- /dev/null +++ b/docs/guide/timezones.md @@ -0,0 +1,9 @@ +# Timezones + +What is considered a "day's worth of games" is determined by the reset time. The reset time is generally at midnight everyday after which newer games are counted towards the next day. Reset times vary from region to region: + +- North America: UTC-5:00 (Central North American Time midnight) +- Europe: UTC+1:00 (Central European Time midnight) +- Asia: UTC+7:00 (Central Asia Standard Time midnight) + +**Reset times are different from Blitz Stars** (Blitz Stars resets at 5:00 am locally relative to the user opening their website). Inconsistencies with Blitz Stars only occur with sleep-deprived players and players who play in the wrong region. diff --git a/src/commands/help.ts b/src/commands/help.ts index 210a68980..c5bd5135f 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -1,44 +1,51 @@ -import { SlashCommandBuilder } from 'discord.js'; +import { + SlashCommandBuilder, + SlashCommandSubcommandsOnlyBuilder, +} from 'discord.js'; import { COMMANDS_RAW, CommandRegistry, } from '../events/interactionCreate/index.js'; const RAW_PATH = `https://raw.githubusercontent.com/tresabhi/blitzkrieg/main/docs/`; -const DOCS: Record = { +const DOCS = { permissions: 'guide/permissions', embeds: 'guide/embeds', about: 'guide/about', invite: 'guide/invite', + timezones: 'guide/timezones', }; +const DOC_DESCRIPTIONS: Record = { + permissions: 'The permissions needed for the bot to function', + embeds: 'How embeds work', + about: 'About the bot', + invite: 'How to invite the bot', + timezones: 'How Blitzkrieg infers and uses your timezone', +}; + +function addDocsSubcommands(option: SlashCommandSubcommandsOnlyBuilder) { + Object.entries(DOC_DESCRIPTIONS).forEach(([key, value]) => { + option.addSubcommand((sub) => sub.setName(key).setDescription(value)); + }); + + return option; +} export const helpCommand: CommandRegistry = { inProduction: true, inDevelopment: true, inPublic: true, - command: new SlashCommandBuilder() - .setName('help') - .setDescription('All the help you need about the bot') - .addSubcommand((option) => - option - .setName('commands') - .setDescription('List of all commands and their descriptions'), - ) - .addSubcommand((option) => - option - .setName('permissions') - .setDescription('The permissions needed for the bot to function'), - ) - .addSubcommand((option) => - option.setName('about').setDescription('About the bot'), - ) - .addSubcommand((option) => - option.setName('embeds').setDescription('How embeds work'), - ) - .addSubcommand((option) => - option.setName('invite').setDescription('How to invite the bot'), - ), + command: addDocsSubcommands( + new SlashCommandBuilder() + .setName('help') + .setDescription('All the help you need about the bot') + .addSubcommand((option) => + option + .setName('commands') + .setDescription('List of all commands and their descriptions'), + ), + ), handler(interaction) { const subcommand = interaction.options.getSubcommand(); @@ -54,7 +61,7 @@ export const helpCommand: CommandRegistry = { .join('\n')}`; } - const url = `${RAW_PATH}${DOCS[subcommand]}.md`; + const url = `${RAW_PATH}${DOCS[subcommand as keyof typeof DOCS]}.md`; const content = fetch(url).then((response) => response.text()); return content; From 21158e908168ece351b651baca3ddf7f590fe63a Mon Sep 17 00:00:00 2001 From: tresabhi Date: Tue, 11 Jul 2023 19:43:22 +0000 Subject: [PATCH 23/26] feat: updated /fullstats with figma --- docs/guide/timezones.md | 6 +- src/commands/fullStats.tsx | 2 +- src/commands/help.ts | 2 +- src/components/GenericAllStats.tsx | 60 --------- .../GenericAllStats/components/Card.tsx | 91 +++++++++++++ .../GenericAllStats/components/Root.tsx | 17 +++ .../GenericAllStats/components/Row.tsx | 7 + src/components/GenericAllStats/index.tsx | 124 ++++++++++++++++++ src/renderers/fullStats.tsx | 2 +- src/routes/today.tsx | 2 +- 10 files changed, 246 insertions(+), 67 deletions(-) delete mode 100644 src/components/GenericAllStats.tsx create mode 100644 src/components/GenericAllStats/components/Card.tsx create mode 100644 src/components/GenericAllStats/components/Root.tsx create mode 100644 src/components/GenericAllStats/components/Row.tsx create mode 100644 src/components/GenericAllStats/index.tsx diff --git a/docs/guide/timezones.md b/docs/guide/timezones.md index 3b344cc55..631450aaf 100644 --- a/docs/guide/timezones.md +++ b/docs/guide/timezones.md @@ -2,8 +2,8 @@ What is considered a "day's worth of games" is determined by the reset time. The reset time is generally at midnight everyday after which newer games are counted towards the next day. Reset times vary from region to region: -- North America: UTC-5:00 (Central North American Time midnight) -- Europe: UTC+1:00 (Central European Time midnight) -- Asia: UTC+7:00 (Central Asia Standard Time midnight) +- North America: `UTC-5:00` (Central North American Time midnight) +- Europe: `UTC+1:00` (Central European Time midnight) +- Asia: `UTC+7:00` (Central Asia Standard Time midnight) **Reset times are different from Blitz Stars** (Blitz Stars resets at 5:00 am locally relative to the user opening their website). Inconsistencies with Blitz Stars only occur with sleep-deprived players and players who play in the wrong region. diff --git a/src/commands/fullStats.tsx b/src/commands/fullStats.tsx index 4991a4bb6..cfe3bdace 100644 --- a/src/commands/fullStats.tsx +++ b/src/commands/fullStats.tsx @@ -19,7 +19,7 @@ import { AccountInfo } from '../types/accountInfo.js'; export const fullStatsCommand: CommandRegistry = { inProduction: true, - inDevelopment: false, + inDevelopment: true, inPublic: true, command: addStatTypeSubCommandGroups( diff --git a/src/commands/help.ts b/src/commands/help.ts index c5bd5135f..711041db2 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -33,7 +33,7 @@ function addDocsSubcommands(option: SlashCommandSubcommandsOnlyBuilder) { export const helpCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: addDocsSubcommands( diff --git a/src/components/GenericAllStats.tsx b/src/components/GenericAllStats.tsx deleted file mode 100644 index 54ff834f3..000000000 --- a/src/components/GenericAllStats.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import getWN8Percentile from '../core/blitz/getWN8Percentile.js'; -import isNumber from '../core/node/isNumber.js'; -import { AllStats, SupplementaryStats } from '../types/accountInfo.js'; -import GenericStats from './GenericStats/index.js'; - -export interface GenericAllStatsProps { - stats: AllStats; - supplementaryStats?: SupplementaryStats; -} - -export default function GenericAllStats({ - stats, - supplementaryStats, -}: GenericAllStatsProps) { - const damageRatio = stats.damage_dealt / stats.damage_received; - const killsToDeathRatio = - stats.frags / (stats.battles - stats.survived_battles); - - return ( - - ); -} diff --git a/src/components/GenericAllStats/components/Card.tsx b/src/components/GenericAllStats/components/Card.tsx new file mode 100644 index 000000000..518c7e5d1 --- /dev/null +++ b/src/components/GenericAllStats/components/Card.tsx @@ -0,0 +1,91 @@ +import { Percentile } from '../../../constants/percentiles.js'; +import { theme } from '../../../stitches.config.js'; +import PercentileIndicator from '../../PercentileIndicator.js'; + +export interface CardItem { + label: string; + value: string | number | undefined; + percentile?: Percentile; +} + +export interface CardProps { + items: CardItem[]; + title: string; +} + +export function Card({ items, title }: CardProps) { + return ( +
+ + {title} + + +
+ {items.map((item) => ( +
+ + {item.label} + + +
+ +
+ {item.percentile !== undefined && ( + + )} + + {item.value === undefined || Number.isNaN(item.value) + ? '--' + : item.value} + +
+
+ ))} +
+
+ ); +} diff --git a/src/components/GenericAllStats/components/Root.tsx b/src/components/GenericAllStats/components/Root.tsx new file mode 100644 index 000000000..0cf26bfde --- /dev/null +++ b/src/components/GenericAllStats/components/Root.tsx @@ -0,0 +1,17 @@ +export interface RootProps { + children: React.ReactNode; +} + +export function Root({ children }: RootProps) { + return ( +
+ {children} +
+ ); +} diff --git a/src/components/GenericAllStats/components/Row.tsx b/src/components/GenericAllStats/components/Row.tsx new file mode 100644 index 000000000..dcb083a60 --- /dev/null +++ b/src/components/GenericAllStats/components/Row.tsx @@ -0,0 +1,7 @@ +export interface RowProps { + children: React.ReactNode; +} + +export function Row({ children }: RowProps) { + return
{children}
; +} diff --git a/src/components/GenericAllStats/index.tsx b/src/components/GenericAllStats/index.tsx new file mode 100644 index 000000000..bb1821b4f --- /dev/null +++ b/src/components/GenericAllStats/index.tsx @@ -0,0 +1,124 @@ +import getWN8Percentile from '../../core/blitz/getWN8Percentile.js'; +import isNumber from '../../core/node/isNumber.js'; +import { AllStats, SupplementaryStats } from '../../types/accountInfo.js'; +import { Card } from './components/Card.js'; +import { Root } from './components/Root.js'; +import { Row } from './components/Row.js'; + +// TODO: remove the .js endings + +export interface GenericAllStatsProps { + stats: AllStats; + supplementaryStats?: SupplementaryStats; +} + +export default function GenericAllStats({ + stats, + supplementaryStats, +}: GenericAllStatsProps) { + const damageRatio = stats.damage_dealt / stats.damage_received; + const killsToDeathRatio = + stats.frags / (stats.battles - stats.survived_battles); + + return ( + + + + + + + + + + + ); +} diff --git a/src/renderers/fullStats.tsx b/src/renderers/fullStats.tsx index 698d8794a..a9ecae06e 100644 --- a/src/renderers/fullStats.tsx +++ b/src/renderers/fullStats.tsx @@ -1,4 +1,4 @@ -import GenericAllStats from '../components/GenericAllStats.js'; +import GenericAllStats from '../components/GenericAllStats/index.js'; import NoData, { NoDataType } from '../components/NoData.js'; import PoweredBy, { PoweredByType } from '../components/PoweredBy.js'; import TierWeights, { TierWeightsRecord } from '../components/TierWeights.js'; diff --git a/src/routes/today.tsx b/src/routes/today.tsx index b4bf67298..257c79473 100644 --- a/src/routes/today.tsx +++ b/src/routes/today.tsx @@ -5,7 +5,7 @@ import { RouteRegistry } from '../server.js'; export const todayRoute: RouteRegistry = { route: '/today', inProduction: true, - inDevelopment: true, + inDevelopment: false, async handler(req) { const player = resolvePlayerFromRequest(req); From 1d4ac2f133378e014089fdde1a7850c796d1a337 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Tue, 11 Jul 2023 19:54:57 +0000 Subject: [PATCH 24/26] feat: switched to Node module resolution --- CODE_OF_CONDUCT.md | 22 ++++---- docs/.vitepress/theme/index.ts | 12 ++--- docs/.vitepress/theme/style.css | 3 +- package.json | 4 +- src/bot.ts | 10 ++-- src/commands/debug.ts | 14 ++--- src/commands/eligible.ts | 34 ++++++------ src/commands/evolution.tsx | 36 ++++++------- src/commands/fullStats.tsx | 34 ++++++------ src/commands/help.ts | 5 +- src/commands/inactive.tsx | 28 +++++----- src/commands/ownedTanks.tsx | 36 ++++++------- src/commands/ping.ts | 2 +- src/commands/playerAchievements.ts | 22 ++++---- src/commands/playerInfo.ts | 18 +++---- src/commands/searchClans.ts | 16 +++--- src/commands/searchPlayers.ts | 18 +++---- src/commands/searchTanks.ts | 8 +-- src/commands/stats.tsx | 36 ++++++------- src/commands/today.tsx | 26 +++++----- src/commands/verify.ts | 20 +++---- .../components/WN8Display/components/Glow.tsx | 6 +-- .../components/WN8Display/index.tsx | 10 ++-- .../components/WN8SurroundingStat.tsx | 2 +- src/components/AllStatsOverview/index.tsx | 6 +-- src/components/Breakdown/components/Row.tsx | 8 +-- .../Breakdown/components/RowDiscriminator.tsx | 2 +- .../Breakdown/components/RowStat.tsx | 6 +-- src/components/Breakdown/index.ts | 8 +-- .../GenericAllStats/components/Card.tsx | 6 +-- src/components/GenericAllStats/index.tsx | 12 ++--- .../components/GenericStatsColumn.tsx | 4 +- .../components/GenericStatsRow.tsx | 6 +-- src/components/GenericStats/index.tsx | 4 +- src/components/Graph/components/Line.tsx | 2 +- src/components/Graph/components/Margin.tsx | 4 +- src/components/Graph/components/Root.tsx | 4 +- src/components/Graph/index.ts | 6 +-- src/components/NoData.tsx | 2 +- src/components/PercentileIndicator.tsx | 2 +- src/components/PoweredBy.tsx | 2 +- src/components/Tanks/components/Item.tsx | 4 +- src/components/Tanks/index.ts | 6 +-- src/components/TierWeights.tsx | 4 +- src/components/TitleBar.tsx | 4 +- src/components/Wrapper.tsx | 2 +- src/core/blitz/calculateWN8.ts | 2 +- src/core/blitz/diffStats.ts | 2 +- src/core/blitz/getBlitzClan.ts | 8 +-- src/core/blitz/getTankStats.ts | 10 ++-- src/core/blitz/getTreeType.ts | 4 +- src/core/blitz/getWN8Percentile.ts | 2 +- src/core/blitz/getWargamingResponse.ts | 2 +- src/core/blitz/listClans.ts | 8 +-- src/core/blitz/listPlayers.ts | 8 +-- src/core/blitz/resolveTankId.ts | 4 +- src/core/blitz/resolveTankName.ts | 2 +- src/core/blitz/sumStats.ts | 4 +- src/core/blitzstars/getDiffedTankStats.ts | 6 +-- src/core/blitzstars/getPeriodStart.ts | 6 +-- src/core/blitzstars/getPlayerHistories.ts | 14 ++--- src/core/blitzstars/getTankHistories.ts | 10 ++-- src/core/blitzstars/getTimeDaysAgo.ts | 2 +- src/core/blitzstars/playerAverage.ts | 6 +-- src/core/blitzstars/tankAverages.ts | 2 +- src/core/discord/addPeriodSubCommands.ts | 2 +- src/core/discord/addServerChoices.ts | 2 +- .../discord/addStatTypeSubCommandGroups.ts | 6 +-- src/core/discord/autocompleteClan.ts | 6 +-- src/core/discord/autocompleteTanks.ts | 11 ++-- src/core/discord/autocompleteUsername.ts | 6 +-- src/core/discord/embedInfo.ts | 2 +- src/core/discord/embedNegative.ts | 2 +- src/core/discord/embedPositive.ts | 2 +- src/core/discord/embedWarning.ts | 2 +- .../discord/normalizeInteractionReturnable.ts | 4 +- src/core/discord/resolvePeriodFromButton.ts | 6 +-- src/core/discord/resolvePeriodFromCommand.ts | 10 ++-- src/core/discord/resolvePlayerFromButton.ts | 4 +- src/core/discord/resolvePlayerFromCommand.ts | 6 +-- src/core/express/normalizeRouteReturnable.ts | 4 +- src/core/express/resolvePeriodFromRequest.ts | 6 +-- src/core/express/resolvePeriodFromURL.ts | 12 ++--- src/core/express/resolvePlayerFromRequest.ts | 4 +- src/core/express/resolvePlayerFromURL.ts | 4 +- src/core/node/getClientId.ts | 2 +- src/core/node/jsxToPng.ts | 4 +- src/core/node/svgToPng.ts | 6 +-- src/events/error.ts | 6 +-- src/events/guildMemberAdd.ts | 2 +- .../handlers/autocomplete.ts | 2 +- .../interactionCreate/handlers/button.tsx | 8 +-- .../handlers/chatInputCommand.ts | 12 ++--- src/events/interactionCreate/index.ts | 44 ++++++++-------- src/events/ready.ts | 2 +- src/renderers/evolution.tsx | 36 ++++++------- src/renderers/fullStats.tsx | 40 +++++++------- src/renderers/stats.tsx | 42 +++++++-------- src/renderers/today.tsx | 42 +++++++-------- src/routes/stats.tsx | 8 +-- src/routes/today.tsx | 6 +-- src/server.ts | 12 ++--- src/types/clanInfo.ts | 52 ++++++++++--------- src/types/histories.ts | 2 +- src/types/possiblyPromise.ts | 2 +- src/types/tanksStats.ts | 2 +- tsconfig.json | 8 +-- yarn.lock | 5 ++ 108 files changed, 541 insertions(+), 533 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 5bb61952c..c8195926a 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the +- Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or +- The use of sexualized language or imagery, and sexual attention or advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an +standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index bdd506d91..107d0ae71 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,16 +1,16 @@ // https://vitepress.dev/guide/custom-theme -import { h } from 'vue' -import Theme from 'vitepress/theme' -import './style.css' +import { h } from 'vue'; +import Theme from 'vitepress/theme'; +import './style.css'; export default { extends: Theme, Layout: () => { return h(Theme.Layout, null, { // https://vitepress.dev/guide/extending-default-theme#layout-slots - }) + }); }, enhanceApp({ app, router, siteData }) { // ... - } -} + }, +}; diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index c23c17ac7..45d673a9e 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -7,7 +7,7 @@ * Colors * -------------------------------------------------------------------------- */ - :root { +:root { --vp-c-brand: #646cff; --vp-c-brand-light: #747bff; --vp-c-brand-lighter: #9499ff; @@ -88,4 +88,3 @@ .DocSearch { --docsearch-primary-color: var(--vp-c-brand) !important; } - diff --git a/package.json b/package.json index f01ffccb2..296a85345 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "start:server": "node --enable-source-maps --trace-warnings dist/server.cjs", "host:docs": "vitepress preview docs", "zip": "zip -r dist.zip dist", - "lint": "npx tsc" + "lint": "npx tsc", + "format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"" }, "license": "MIT", "dependencies": { @@ -42,6 +43,7 @@ "@types/markdown-escape": "^1.1.0", "@types/node": "^20.2.1", "@types/react": "^18.2.7", + "prettier": "^3.0.0", "typescript": "^5.0.4", "vitepress": "^1.0.0-beta.3" } diff --git a/src/bot.ts b/src/bot.ts index 8d66081c8..8297d739e 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,9 +1,9 @@ import { Client, GatewayIntentBits } from 'discord.js'; -import { DISCORD_TOKEN } from './core/node/arguments.js'; -import { registerErrorHandlers } from './events/error.js'; -import guildMemberAdd from './events/guildMemberAdd.js'; -import interactionCreate from './events/interactionCreate/index.js'; -import ready from './events/ready.js'; +import { DISCORD_TOKEN } from './core/node/arguments'; +import { registerErrorHandlers } from './events/error'; +import guildMemberAdd from './events/guildMemberAdd'; +import interactionCreate from './events/interactionCreate'; +import ready from './events/ready'; export const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers], diff --git a/src/commands/debug.ts b/src/commands/debug.ts index 59a47d30b..76bd7c807 100644 --- a/src/commands/debug.ts +++ b/src/commands/debug.ts @@ -1,12 +1,12 @@ import { SlashCommandBuilder } from 'discord.js'; import packageJSON from '../../package.json' assert { type: 'json' }; -import { client } from '../bot.js'; -import { tankopedia } from '../core/blitz/tankopedia.js'; -import { tankAverages } from '../core/blitzstars/tankAverages.js'; -import embedInfo from '../core/discord/embedInfo.js'; -import markdownTable from '../core/discord/markdownTable.js'; -import getClientId from '../core/node/getClientId.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; +import { client } from '../bot'; +import { tankopedia } from '../core/blitz/tankopedia'; +import { tankAverages } from '../core/blitzstars/tankAverages'; +import embedInfo from '../core/discord/embedInfo'; +import markdownTable from '../core/discord/markdownTable'; +import getClientId from '../core/node/getClientId'; +import { CommandRegistry } from '../events/interactionCreate'; const executionStart = new Date().getTime(); diff --git a/src/commands/eligible.ts b/src/commands/eligible.ts index db3c77e00..43c6991d6 100644 --- a/src/commands/eligible.ts +++ b/src/commands/eligible.ts @@ -1,21 +1,21 @@ import { SlashCommandBuilder } from 'discord.js'; -import calculateWN8 from '../core/blitz/calculateWN8.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import sumStats from '../core/blitz/sumStats.js'; -import { tankopedia } from '../core/blitz/tankopedia.js'; -import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats.js'; -import getPeriodNow from '../core/blitzstars/getPeriodNow.js'; -import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo.js'; -import { tankAverages } from '../core/blitzstars/tankAverages.js'; -import addUsernameChoices from '../core/discord/addUsernameChoices.js'; -import embedNegative from '../core/discord/embedNegative.js'; -import embedPositive from '../core/discord/embedPositive.js'; -import markdownTable, { TableInput } from '../core/discord/markdownTable.js'; -import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import { AccountInfo } from '../types/accountInfo.js'; -import { PossiblyPromise } from '../types/possiblyPromise.js'; +import calculateWN8 from '../core/blitz/calculateWN8'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import sumStats from '../core/blitz/sumStats'; +import { tankopedia } from '../core/blitz/tankopedia'; +import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats'; +import getPeriodNow from '../core/blitzstars/getPeriodNow'; +import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo'; +import { tankAverages } from '../core/blitzstars/tankAverages'; +import addUsernameChoices from '../core/discord/addUsernameChoices'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import { AccountInfo } from '../types/accountInfo'; +import { PossiblyPromise } from '../types/possiblyPromise'; export type SkilledClan = 'SKLLD' | 'SMRI'; diff --git a/src/commands/evolution.tsx b/src/commands/evolution.tsx index 555f1dd1f..e3b62fbe4 100644 --- a/src/commands/evolution.tsx +++ b/src/commands/evolution.tsx @@ -1,22 +1,22 @@ import { SlashCommandBuilder } from 'discord.js'; -import { CYCLIC_API } from '../constants/cyclic.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import resolveTankId from '../core/blitz/resolveTankId.js'; -import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups.js'; -import autocompleteTanks from '../core/discord/autocompleteTanks.js'; -import autocompleteUsername from '../core/discord/autocompleteUsername.js'; -import interactionToURL from '../core/discord/interactionToURL.js'; -import linkButton from '../core/discord/linkButton.js'; -import primaryButton from '../core/discord/primaryButton.js'; -import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton.js'; -import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand.js'; -import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js'; -import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import evolution from '../renderers/evolution.js'; -import { StatType } from '../renderers/fullStats.js'; -import { AccountInfo } from '../types/accountInfo.js'; +import { CYCLIC_API } from '../constants/cyclic'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import resolveTankId from '../core/blitz/resolveTankId'; +import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups'; +import autocompleteTanks from '../core/discord/autocompleteTanks'; +import autocompleteUsername from '../core/discord/autocompleteUsername'; +import interactionToURL from '../core/discord/interactionToURL'; +import linkButton from '../core/discord/linkButton'; +import primaryButton from '../core/discord/primaryButton'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import evolution from '../renderers/evolution'; +import { StatType } from '../renderers/fullStats'; +import { AccountInfo } from '../types/accountInfo'; export const evolutionCommand: CommandRegistry = { inProduction: true, diff --git a/src/commands/fullStats.tsx b/src/commands/fullStats.tsx index cfe3bdace..de1cdaa85 100644 --- a/src/commands/fullStats.tsx +++ b/src/commands/fullStats.tsx @@ -1,21 +1,21 @@ import { SlashCommandBuilder } from 'discord.js'; -import { CYCLIC_API } from '../constants/cyclic.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import resolveTankId from '../core/blitz/resolveTankId.js'; -import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups.js'; -import autocompleteTanks from '../core/discord/autocompleteTanks.js'; -import autocompleteUsername from '../core/discord/autocompleteUsername.js'; -import interactionToURL from '../core/discord/interactionToURL.js'; -import linkButton from '../core/discord/linkButton.js'; -import primaryButton from '../core/discord/primaryButton.js'; -import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton.js'; -import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand.js'; -import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js'; -import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import fullStats, { StatType } from '../renderers/fullStats.js'; -import { AccountInfo } from '../types/accountInfo.js'; +import { CYCLIC_API } from '../constants/cyclic'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import resolveTankId from '../core/blitz/resolveTankId'; +import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups'; +import autocompleteTanks from '../core/discord/autocompleteTanks'; +import autocompleteUsername from '../core/discord/autocompleteUsername'; +import interactionToURL from '../core/discord/interactionToURL'; +import linkButton from '../core/discord/linkButton'; +import primaryButton from '../core/discord/primaryButton'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import fullStats, { StatType } from '../renderers/fullStats'; +import { AccountInfo } from '../types/accountInfo'; export const fullStatsCommand: CommandRegistry = { inProduction: true, diff --git a/src/commands/help.ts b/src/commands/help.ts index 711041db2..2052fd12a 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -2,10 +2,7 @@ import { SlashCommandBuilder, SlashCommandSubcommandsOnlyBuilder, } from 'discord.js'; -import { - COMMANDS_RAW, - CommandRegistry, -} from '../events/interactionCreate/index.js'; +import { COMMANDS_RAW, CommandRegistry } from '../events/interactionCreate'; const RAW_PATH = `https://raw.githubusercontent.com/tresabhi/blitzkrieg/main/docs/`; const DOCS = { diff --git a/src/commands/inactive.tsx b/src/commands/inactive.tsx index 987f6568d..4b904833d 100644 --- a/src/commands/inactive.tsx +++ b/src/commands/inactive.tsx @@ -1,18 +1,18 @@ import { SlashCommandBuilder } from 'discord.js'; -import GenericStats from '../components/GenericStats/index.js'; -import NoData, { NoDataType } from '../components/NoData.js'; -import PoweredBy, { PoweredByType } from '../components/PoweredBy.js'; -import TitleBar from '../components/TitleBar.js'; -import Wrapper from '../components/Wrapper.js'; -import { BLITZ_SERVERS } from '../constants/servers.js'; -import getBlitzClan from '../core/blitz/getBlitzClan.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import addClanChoices from '../core/discord/addClanChoices.js'; -import autocompleteClan from '../core/discord/autocompleteClan.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import { AccountInfo } from '../types/accountInfo.js'; -import { ClanInfo } from '../types/clanInfo.js'; +import GenericStats from '../components/GenericStats'; +import NoData, { NoDataType } from '../components/NoData'; +import PoweredBy, { PoweredByType } from '../components/PoweredBy'; +import TitleBar from '../components/TitleBar'; +import Wrapper from '../components/Wrapper'; +import { BLITZ_SERVERS } from '../constants/servers'; +import getBlitzClan from '../core/blitz/getBlitzClan'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import addClanChoices from '../core/discord/addClanChoices'; +import autocompleteClan from '../core/discord/autocompleteClan'; +import { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import { AccountInfo } from '../types/accountInfo'; +import { ClanInfo } from '../types/clanInfo'; const DEFAULT_THRESHOLD = 7; diff --git a/src/commands/ownedTanks.tsx b/src/commands/ownedTanks.tsx index d02575688..b43aafd68 100644 --- a/src/commands/ownedTanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -1,26 +1,26 @@ import { SlashCommandBuilder } from 'discord.js'; -import NoData, { NoDataType } from '../components/NoData.js'; -import PoweredBy, { PoweredByType } from '../components/PoweredBy.js'; -import * as Tanks from '../components/Tanks/index.js'; -import TitleBar from '../components/TitleBar.js'; -import Wrapper from '../components/Wrapper.js'; -import { BLITZ_SERVERS } from '../constants/servers.js'; -import getTankStats from '../core/blitz/getTankStats.js'; -import getTreeType from '../core/blitz/getTreeType.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import resolveTankName from '../core/blitz/resolveTankName.js'; +import NoData, { NoDataType } from '../components/NoData'; +import PoweredBy, { PoweredByType } from '../components/PoweredBy'; +import * as Tanks from '../components/Tanks'; +import TitleBar from '../components/TitleBar'; +import Wrapper from '../components/Wrapper'; +import { BLITZ_SERVERS } from '../constants/servers'; +import getTankStats from '../core/blitz/getTankStats'; +import getTreeType from '../core/blitz/getTreeType'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import resolveTankName from '../core/blitz/resolveTankName'; import { TIER_ROMAN_NUMERALS, Tier, tankopedia, -} from '../core/blitz/tankopedia.js'; -import addUsernameChoices from '../core/discord/addUsernameChoices.js'; -import autocompleteUsername from '../core/discord/autocompleteUsername.js'; -import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import { AccountInfo } from '../types/accountInfo.js'; -import { PlayerClanData } from '../types/playerClanData.js'; +} from '../core/blitz/tankopedia'; +import addUsernameChoices from '../core/discord/addUsernameChoices'; +import autocompleteUsername from '../core/discord/autocompleteUsername'; +import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand'; +import { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import { AccountInfo } from '../types/accountInfo'; +import { PlayerClanData } from '../types/playerClanData'; const COMP_TANKS = [ // light tanks diff --git a/src/commands/ping.ts b/src/commands/ping.ts index 71e2bde94..2005400f0 100644 --- a/src/commands/ping.ts +++ b/src/commands/ping.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from 'discord.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; +import { CommandRegistry } from '../events/interactionCreate'; export const pingCommand: CommandRegistry = { inProduction: true, diff --git a/src/commands/playerAchievements.ts b/src/commands/playerAchievements.ts index a0a6d41d9..3301e5542 100644 --- a/src/commands/playerAchievements.ts +++ b/src/commands/playerAchievements.ts @@ -1,18 +1,16 @@ import { SlashCommandBuilder } from 'discord.js'; import { startCase } from 'lodash'; import markdownEscape from 'markdown-escape'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import addUsernameChoices from '../core/discord/addUsernameChoices.js'; -import autocompleteUsername from '../core/discord/autocompleteUsername.js'; -import embedInfo from '../core/discord/embedInfo.js'; -import markdownTable, { - TableInputEntry, -} from '../core/discord/markdownTable.js'; -import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import { AccountAchievements } from '../types/accountAchievements.js'; -import { AccountInfo } from '../types/accountInfo.js'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import { AccountAchievements } from '../types/accountAchievements'; +import { AccountInfo } from '../types/accountInfo'; type SortBy = 'name' | 'count'; diff --git a/src/commands/playerInfo.ts b/src/commands/playerInfo.ts index d33e2f06a..d6661373f 100644 --- a/src/commands/playerInfo.ts +++ b/src/commands/playerInfo.ts @@ -1,14 +1,14 @@ import { SlashCommandBuilder } from 'discord.js'; import markdownEscape from 'markdown-escape'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import addUsernameChoices from '../core/discord/addUsernameChoices.js'; -import autocompleteUsername from '../core/discord/autocompleteUsername.js'; -import embedInfo from '../core/discord/embedInfo.js'; -import markdownTable from '../core/discord/markdownTable.js'; -import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import { AccountInfo } from '../types/accountInfo.js'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import { AccountInfo } from '../types/accountInfo'; export const playerInfoCommand: CommandRegistry = { inProduction: true, diff --git a/src/commands/searchClans.ts b/src/commands/searchClans.ts index 64980acde..6b0e9581c 100644 --- a/src/commands/searchClans.ts +++ b/src/commands/searchClans.ts @@ -1,13 +1,13 @@ import { SlashCommandBuilder } from 'discord.js'; import markdownEscape from 'markdown-escape'; -import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import addClanChoices from '../core/discord/addClanChoices.js'; -import addServerChoices from '../core/discord/addServerChoices.js'; -import embedInfo from '../core/discord/embedInfo.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import { ClanList } from '../types/clanList.js'; +import { BLITZ_SERVERS, BlitzServer } from '../constants/servers'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import addClanChoices from '../core/discord/addClanChoices'; +import addServerChoices from '../core/discord/addServerChoices'; +import embedInfo from '../core/discord/embedInfo'; +import { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import { ClanList } from '../types/clanList'; export const searchClansCommand: CommandRegistry = { inProduction: true, diff --git a/src/commands/searchPlayers.ts b/src/commands/searchPlayers.ts index 4db2f37e4..ad6f0bbc5 100644 --- a/src/commands/searchPlayers.ts +++ b/src/commands/searchPlayers.ts @@ -1,14 +1,14 @@ import { SlashCommandBuilder } from 'discord.js'; import markdownEscape from 'markdown-escape'; -import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import { usernamePattern } from '../core/blitz/listPlayers.js'; -import addServerChoices from '../core/discord/addServerChoices.js'; -import addUsernameChoices from '../core/discord/addUsernameChoices.js'; -import embedInfo from '../core/discord/embedInfo.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import { AccountList } from '../types/accountList.js'; +import { BLITZ_SERVERS, BlitzServer } from '../constants/servers'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import { usernamePattern } from '../core/blitz/listPlayers'; +import addServerChoices from '../core/discord/addServerChoices'; +import addUsernameChoices from '../core/discord/addUsernameChoices'; +import embedInfo from '../core/discord/embedInfo'; +import { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import { AccountList } from '../types/accountList'; export const searchPlayersCommand: CommandRegistry = { inProduction: true, diff --git a/src/commands/searchTanks.ts b/src/commands/searchTanks.ts index ac859b7d1..7f1e87ab3 100644 --- a/src/commands/searchTanks.ts +++ b/src/commands/searchTanks.ts @@ -1,10 +1,10 @@ import { SlashCommandBuilder } from 'discord.js'; import { go } from 'fuzzysort'; import markdownEscape from 'markdown-escape'; -import { TANK_NAMES } from '../core/blitz/tankopedia.js'; -import addTankChoices from '../core/discord/addTankChoices.js'; -import embedInfo from '../core/discord/embedInfo.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; +import { TANK_NAMES } from '../core/blitz/tankopedia'; +import addTankChoices from '../core/discord/addTankChoices'; +import embedInfo from '../core/discord/embedInfo'; +import { CommandRegistry } from '../events/interactionCreate'; export const searchTanksCommand: CommandRegistry = { inProduction: true, diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index d302a286e..4f5f5721f 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -1,22 +1,22 @@ import { SlashCommandBuilder } from 'discord.js'; -import { CYCLIC_API } from '../constants/cyclic.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import resolveTankId from '../core/blitz/resolveTankId.js'; -import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups.js'; -import autocompleteTanks from '../core/discord/autocompleteTanks.js'; -import autocompleteUsername from '../core/discord/autocompleteUsername.js'; -import interactionToURL from '../core/discord/interactionToURL.js'; -import linkButton from '../core/discord/linkButton.js'; -import primaryButton from '../core/discord/primaryButton.js'; -import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton.js'; -import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand.js'; -import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js'; -import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import { StatType } from '../renderers/fullStats.js'; -import stats from '../renderers/stats.js'; -import { AccountInfo } from '../types/accountInfo.js'; +import { CYCLIC_API } from '../constants/cyclic'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import resolveTankId from '../core/blitz/resolveTankId'; +import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups'; +import autocompleteTanks from '../core/discord/autocompleteTanks'; +import autocompleteUsername from '../core/discord/autocompleteUsername'; +import interactionToURL from '../core/discord/interactionToURL'; +import linkButton from '../core/discord/linkButton'; +import primaryButton from '../core/discord/primaryButton'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import { StatType } from '../renderers/fullStats'; +import stats from '../renderers/stats'; +import { AccountInfo } from '../types/accountInfo'; export const statsCommand: CommandRegistry = { inProduction: true, diff --git a/src/commands/today.tsx b/src/commands/today.tsx index 3b269819c..7026723fd 100644 --- a/src/commands/today.tsx +++ b/src/commands/today.tsx @@ -1,17 +1,17 @@ import { SlashCommandBuilder } from 'discord.js'; -import { CYCLIC_API } from '../constants/cyclic.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import addUsernameChoices from '../core/discord/addUsernameChoices.js'; -import autocompleteUsername from '../core/discord/autocompleteUsername.js'; -import interactionToURL from '../core/discord/interactionToURL.js'; -import linkButton from '../core/discord/linkButton.js'; -import primaryButton from '../core/discord/primaryButton.js'; -import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js'; -import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import today from '../renderers/today.js'; -import { AccountInfo } from '../types/accountInfo.js'; +import { CYCLIC_API } from '../constants/cyclic'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import addUsernameChoices from '../core/discord/addUsernameChoices'; +import autocompleteUsername from '../core/discord/autocompleteUsername'; +import interactionToURL from '../core/discord/interactionToURL'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import today from '../renderers/today'; +import { AccountInfo } from '../types/accountInfo'; export const todayCommand: CommandRegistry = { inProduction: true, diff --git a/src/commands/verify.ts b/src/commands/verify.ts index c3cfb4b59..66c78d35e 100644 --- a/src/commands/verify.ts +++ b/src/commands/verify.ts @@ -1,16 +1,16 @@ import { SlashCommandBuilder } from 'discord.js'; import markdownEscape from 'markdown-escape'; import discord from '../../discord.json' assert { type: 'json' }; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import addUsernameChoices from '../core/discord/addUsernameChoices.js'; -import autocompleteUsername from '../core/discord/autocompleteUsername.js'; -import embedNegative from '../core/discord/embedNegative.js'; -import embedPositive from '../core/discord/embedPositive.js'; -import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { CommandRegistry } from '../events/interactionCreate/index.js'; -import { AccountInfo } from '../types/accountInfo.js'; -import { PlayerClanData } from '../types/playerClanData.js'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { CommandRegistry } from '../events/interactionCreate'; +import { AccountInfo } from '../types/accountInfo'; +import { PlayerClanData } from '../types/playerClanData'; export const verifyCommand: CommandRegistry = { inProduction: true, diff --git a/src/components/AllStatsOverview/components/WN8Display/components/Glow.tsx b/src/components/AllStatsOverview/components/WN8Display/components/Glow.tsx index 7c5d2f93e..d1acbffd4 100644 --- a/src/components/AllStatsOverview/components/WN8Display/components/Glow.tsx +++ b/src/components/AllStatsOverview/components/WN8Display/components/Glow.tsx @@ -1,6 +1,6 @@ -import { Percentile } from '../../../../../constants/percentiles.js'; -import hslToHex from '../../../../../core/node/hslToHex.js'; -import { PERCENTILE_COLORS } from '../../../../PercentileIndicator.js'; +import { Percentile } from '../../../../../constants/percentiles'; +import hslToHex from '../../../../../core/node/hslToHex'; +import { PERCENTILE_COLORS } from '../../../../PercentileIndicator'; export enum GlowSide { Top, diff --git a/src/components/AllStatsOverview/components/WN8Display/index.tsx b/src/components/AllStatsOverview/components/WN8Display/index.tsx index 08f257fe2..4fd0da495 100644 --- a/src/components/AllStatsOverview/components/WN8Display/index.tsx +++ b/src/components/AllStatsOverview/components/WN8Display/index.tsx @@ -1,8 +1,8 @@ -import { Percentile } from '../../../../constants/percentiles.js'; -import getWN8Percentile from '../../../../core/blitz/getWN8Percentile.js'; -import { theme } from '../../../../stitches.config.js'; -import { PERCENTILE_COLORS } from '../../../PercentileIndicator.js'; -import { Glow, GlowSide } from './components/Glow.js'; +import { Percentile } from '../../../../constants/percentiles'; +import getWN8Percentile from '../../../../core/blitz/getWN8Percentile'; +import { theme } from '../../../../stitches.config'; +import { PERCENTILE_COLORS } from '../../../PercentileIndicator'; +import { Glow, GlowSide } from './components/Glow'; export interface WN8DisplayProps { WN8?: number; diff --git a/src/components/AllStatsOverview/components/WN8SurroundingStat.tsx b/src/components/AllStatsOverview/components/WN8SurroundingStat.tsx index 4c48d00fa..807e2eb50 100644 --- a/src/components/AllStatsOverview/components/WN8SurroundingStat.tsx +++ b/src/components/AllStatsOverview/components/WN8SurroundingStat.tsx @@ -1,4 +1,4 @@ -import { theme } from '../../../stitches.config.js'; +import { theme } from '../../../stitches.config'; export enum WN8SurroundingStatAlign { Left, diff --git a/src/components/AllStatsOverview/index.tsx b/src/components/AllStatsOverview/index.tsx index e1d309e4e..da7ba6c34 100644 --- a/src/components/AllStatsOverview/index.tsx +++ b/src/components/AllStatsOverview/index.tsx @@ -1,9 +1,9 @@ -import { AllStats, SupplementaryStats } from '../../types/accountInfo.js'; -import { WN8Display } from './components/WN8Display/index.js'; +import { AllStats, SupplementaryStats } from '../../types/accountInfo'; +import { WN8Display } from './components/WN8Display'; import { WN8SurroundingStat, WN8SurroundingStatAlign, -} from './components/WN8SurroundingStat.js'; +} from './components/WN8SurroundingStat'; export interface AllStatsOverviewProps { stats: AllStats; diff --git a/src/components/Breakdown/components/Row.tsx b/src/components/Breakdown/components/Row.tsx index e418f4b52..c92f28ced 100644 --- a/src/components/Breakdown/components/Row.tsx +++ b/src/components/Breakdown/components/Row.tsx @@ -1,7 +1,7 @@ -import getWN8Percentile from '../../../core/blitz/getWN8Percentile.js'; -import { theme } from '../../../stitches.config.js'; -import { RowDiscriminator } from './RowDiscriminator.js'; -import { RowStat } from './RowStat.js'; +import getWN8Percentile from '../../../core/blitz/getWN8Percentile'; +import { theme } from '../../../stitches.config'; +import { RowDiscriminator } from './RowDiscriminator'; +import { RowStat } from './RowStat'; export interface RowProps { name: string; diff --git a/src/components/Breakdown/components/RowDiscriminator.tsx b/src/components/Breakdown/components/RowDiscriminator.tsx index d70e6fa26..04bc4c2d3 100644 --- a/src/components/Breakdown/components/RowDiscriminator.tsx +++ b/src/components/Breakdown/components/RowDiscriminator.tsx @@ -1,4 +1,4 @@ -import { theme } from '../../../stitches.config.js'; +import { theme } from '../../../stitches.config'; export interface RowDiscriminatorProps { name: string; diff --git a/src/components/Breakdown/components/RowStat.tsx b/src/components/Breakdown/components/RowStat.tsx index c4303b3ef..cf58e3a14 100644 --- a/src/components/Breakdown/components/RowStat.tsx +++ b/src/components/Breakdown/components/RowStat.tsx @@ -1,6 +1,6 @@ -import { Percentile } from '../../../constants/percentiles.js'; -import { theme } from '../../../stitches.config.js'; -import PercentileIndicator from '../../PercentileIndicator.js'; +import { Percentile } from '../../../constants/percentiles'; +import { theme } from '../../../stitches.config'; +import PercentileIndicator from '../../PercentileIndicator'; export interface RowStatProps { name: string; diff --git a/src/components/Breakdown/index.ts b/src/components/Breakdown/index.ts index c66d8dee9..8bb31e1ff 100644 --- a/src/components/Breakdown/index.ts +++ b/src/components/Breakdown/index.ts @@ -1,4 +1,4 @@ -export * from './components/Root.js'; -export * from './components/Row.js'; -export * from './components/RowDiscriminator.js'; -export * from './components/RowStat.js'; +export * from './components/Root'; +export * from './components/Row'; +export * from './components/RowDiscriminator'; +export * from './components/RowStat'; diff --git a/src/components/GenericAllStats/components/Card.tsx b/src/components/GenericAllStats/components/Card.tsx index 518c7e5d1..71fb3d6e5 100644 --- a/src/components/GenericAllStats/components/Card.tsx +++ b/src/components/GenericAllStats/components/Card.tsx @@ -1,6 +1,6 @@ -import { Percentile } from '../../../constants/percentiles.js'; -import { theme } from '../../../stitches.config.js'; -import PercentileIndicator from '../../PercentileIndicator.js'; +import { Percentile } from '../../../constants/percentiles'; +import { theme } from '../../../stitches.config'; +import PercentileIndicator from '../../PercentileIndicator'; export interface CardItem { label: string; diff --git a/src/components/GenericAllStats/index.tsx b/src/components/GenericAllStats/index.tsx index bb1821b4f..2a7784a4b 100644 --- a/src/components/GenericAllStats/index.tsx +++ b/src/components/GenericAllStats/index.tsx @@ -1,9 +1,9 @@ -import getWN8Percentile from '../../core/blitz/getWN8Percentile.js'; -import isNumber from '../../core/node/isNumber.js'; -import { AllStats, SupplementaryStats } from '../../types/accountInfo.js'; -import { Card } from './components/Card.js'; -import { Root } from './components/Root.js'; -import { Row } from './components/Row.js'; +import getWN8Percentile from '../../core/blitz/getWN8Percentile'; +import isNumber from '../../core/node/isNumber'; +import { AllStats, SupplementaryStats } from '../../types/accountInfo'; +import { Card } from './components/Card'; +import { Root } from './components/Root'; +import { Row } from './components/Row'; // TODO: remove the .js endings diff --git a/src/components/GenericStats/components/GenericStatsColumn.tsx b/src/components/GenericStats/components/GenericStatsColumn.tsx index bece9ff4e..e8b3e6f00 100644 --- a/src/components/GenericStats/components/GenericStatsColumn.tsx +++ b/src/components/GenericStats/components/GenericStatsColumn.tsx @@ -1,5 +1,5 @@ -import { Stat } from '../index.js'; -import GenericStatsRow from './GenericStatsRow.js'; +import { Stat } from '..'; +import GenericStatsRow from './GenericStatsRow'; export interface GenericStatsColumnProps { stats: Stat[]; diff --git a/src/components/GenericStats/components/GenericStatsRow.tsx b/src/components/GenericStats/components/GenericStatsRow.tsx index 1630cccb8..1a4e5c7a0 100644 --- a/src/components/GenericStats/components/GenericStatsRow.tsx +++ b/src/components/GenericStats/components/GenericStatsRow.tsx @@ -1,6 +1,6 @@ -import { theme } from '../../../stitches.config.js'; -import PercentileIndicator from '../../PercentileIndicator.js'; -import { Stat } from '../index.js'; +import { Stat } from '..'; +import { theme } from '../../../stitches.config'; +import PercentileIndicator from '../../PercentileIndicator'; export interface GenericStatsRowProps { stat: Stat; diff --git a/src/components/GenericStats/index.tsx b/src/components/GenericStats/index.tsx index 94414baad..b22dce987 100644 --- a/src/components/GenericStats/index.tsx +++ b/src/components/GenericStats/index.tsx @@ -1,5 +1,5 @@ -import { Percentile } from '../../constants/percentiles.js'; -import GenericStatsColumn from './components/GenericStatsColumn.js'; +import { Percentile } from '../../constants/percentiles'; +import GenericStatsColumn from './components/GenericStatsColumn'; export type Stat = | [string, string | number | undefined] diff --git a/src/components/Graph/components/Line.tsx b/src/components/Graph/components/Line.tsx index 3c170eead..8a3e0d0ec 100644 --- a/src/components/Graph/components/Line.tsx +++ b/src/components/Graph/components/Line.tsx @@ -1,5 +1,5 @@ import { blue, green, red, slateDark } from '@radix-ui/colors'; -import { GRAPH_HEIGHT, GRAPH_WIDTH } from './Root.js'; +import { GRAPH_HEIGHT, GRAPH_WIDTH } from './Root'; export enum LineColor { Red, diff --git a/src/components/Graph/components/Margin.tsx b/src/components/Graph/components/Margin.tsx index 6a47082c9..292847455 100644 --- a/src/components/Graph/components/Margin.tsx +++ b/src/components/Graph/components/Margin.tsx @@ -1,6 +1,6 @@ import { times } from 'lodash'; -import { theme } from '../../../stitches.config.js'; -import { MarginInputProps } from './Root.js'; +import { theme } from '../../../stitches.config'; +import { MarginInputProps } from './Root'; export enum MarginOrientation { Vertical, diff --git a/src/components/Graph/components/Root.tsx b/src/components/Graph/components/Root.tsx index ebadd058c..cc5d6df8a 100644 --- a/src/components/Graph/components/Root.tsx +++ b/src/components/Graph/components/Root.tsx @@ -1,7 +1,7 @@ import { times } from 'lodash'; import { ReactNode } from 'react'; -import { theme } from '../../../stitches.config.js'; -import { Margin, MarginOrientation } from './Margin.js'; +import { theme } from '../../../stitches.config'; +import { Margin, MarginOrientation } from './Margin'; export const GRAPH_WIDTH = 544; export const GRAPH_HEIGHT = 320; diff --git a/src/components/Graph/index.ts b/src/components/Graph/index.ts index eceb36006..5aaadb77e 100644 --- a/src/components/Graph/index.ts +++ b/src/components/Graph/index.ts @@ -1,3 +1,3 @@ -export * from './components/Line.js'; -export * from './components/Margin.js'; -export * from './components/Root.js'; +export * from './components/Line'; +export * from './components/Margin'; +export * from './components/Root'; diff --git a/src/components/NoData.tsx b/src/components/NoData.tsx index 003ed8040..3bf47967b 100644 --- a/src/components/NoData.tsx +++ b/src/components/NoData.tsx @@ -1,4 +1,4 @@ -import { theme } from '../stitches.config.js'; +import { theme } from '../stitches.config'; export enum NoDataType { BattlesInPeriod, diff --git a/src/components/PercentileIndicator.tsx b/src/components/PercentileIndicator.tsx index 9a466a562..548a46039 100644 --- a/src/components/PercentileIndicator.tsx +++ b/src/components/PercentileIndicator.tsx @@ -10,7 +10,7 @@ import { teal, yellow, } from '@radix-ui/colors'; -import { Percentile } from '../constants/percentiles.js'; +import { Percentile } from '../constants/percentiles'; export interface PercentileIndicatorProps { percentile: Percentile; diff --git a/src/components/PoweredBy.tsx b/src/components/PoweredBy.tsx index fc376f057..8b224b1d7 100644 --- a/src/components/PoweredBy.tsx +++ b/src/components/PoweredBy.tsx @@ -1,5 +1,5 @@ import { ReactNode } from 'react'; -import { theme } from '../stitches.config.js'; +import { theme } from '../stitches.config'; export enum PoweredByType { BlitzStars, diff --git a/src/components/Tanks/components/Item.tsx b/src/components/Tanks/components/Item.tsx index e0458eeca..d7d2cd546 100644 --- a/src/components/Tanks/components/Item.tsx +++ b/src/components/Tanks/components/Item.tsx @@ -2,8 +2,8 @@ import { TANK_ICONS, TANK_ICONS_COLLECTOR, TANK_ICONS_PREMIUM, -} from '../../../core/blitz/tankopedia.js'; -import { theme } from '../../../stitches.config.js'; +} from '../../../core/blitz/tankopedia'; +import { theme } from '../../../stitches.config'; export enum TreeType { TechTree, diff --git a/src/components/Tanks/index.ts b/src/components/Tanks/index.ts index 4f3bf3609..25362d8dd 100644 --- a/src/components/Tanks/index.ts +++ b/src/components/Tanks/index.ts @@ -1,3 +1,3 @@ -export * from './components/Column.js'; -export * from './components/Item.js'; -export * from './components/Root.js'; +export * from './components/Column'; +export * from './components/Item'; +export * from './components/Root'; diff --git a/src/components/TierWeights.tsx b/src/components/TierWeights.tsx index 21421c11f..f08a7046f 100644 --- a/src/components/TierWeights.tsx +++ b/src/components/TierWeights.tsx @@ -1,5 +1,5 @@ -import { TIER_ROMAN_NUMERALS, Tier } from '../core/blitz/tankopedia.js'; -import { theme } from '../stitches.config.js'; +import { TIER_ROMAN_NUMERALS, Tier } from '../core/blitz/tankopedia'; +import { theme } from '../stitches.config'; export type TierWeightsRecord = Partial>; diff --git a/src/components/TitleBar.tsx b/src/components/TitleBar.tsx index 0366b4fb1..7b5f88a7d 100644 --- a/src/components/TitleBar.tsx +++ b/src/components/TitleBar.tsx @@ -1,5 +1,5 @@ -import isDev from '../core/node/isDev.js'; -import { theme } from '../stitches.config.js'; +import isDev from '../core/node/isDev'; +import { theme } from '../stitches.config'; export interface TitleBarProps { name: string; diff --git a/src/components/Wrapper.tsx b/src/components/Wrapper.tsx index 7062bb7a9..41fadd94a 100644 --- a/src/components/Wrapper.tsx +++ b/src/components/Wrapper.tsx @@ -1,5 +1,5 @@ import { ReactNode } from 'react'; -import { theme } from '../stitches.config.js'; +import { theme } from '../stitches.config'; export interface WrapperProps { children: ReactNode; diff --git a/src/core/blitz/calculateWN8.ts b/src/core/blitz/calculateWN8.ts index 850c2f6ea..1c3a1fc24 100644 --- a/src/core/blitz/calculateWN8.ts +++ b/src/core/blitz/calculateWN8.ts @@ -1,4 +1,4 @@ -import { AllStats } from '../../types/accountInfo.js'; +import { AllStats } from '../../types/accountInfo'; /** * Formula from https://web.archive.org/web/20190105064817/http://wiki.wnefficiency.net/pages/WN8 diff --git a/src/core/blitz/diffStats.ts b/src/core/blitz/diffStats.ts index 3c336d4d2..96cc3694d 100644 --- a/src/core/blitz/diffStats.ts +++ b/src/core/blitz/diffStats.ts @@ -1,4 +1,4 @@ -import { AllStats } from '../../types/accountInfo.js'; +import { AllStats } from '../../types/accountInfo'; export default function diffStats(stats1: AllStats, stats2: AllStats) { function diff(value: (allStats: AllStats) => number) { diff --git a/src/core/blitz/getBlitzClan.ts b/src/core/blitz/getBlitzClan.ts index d8e7c5311..fb4785996 100644 --- a/src/core/blitz/getBlitzClan.ts +++ b/src/core/blitz/getBlitzClan.ts @@ -1,7 +1,7 @@ -import { BlitzServer } from '../../constants/servers.js'; -import { serverAndIdPattern } from '../discord/resolvePlayerFromCommand.js'; -import throwError from '../node/throwError.js'; -import listClans from './listClans.js'; +import { BlitzServer } from '../../constants/servers'; +import { serverAndIdPattern } from '../discord/resolvePlayerFromCommand'; +import throwError from '../node/throwError'; +import listClans from './listClans'; export default async function getBlitzClan(clan: string) { if (serverAndIdPattern.test(clan)) { diff --git a/src/core/blitz/getTankStats.ts b/src/core/blitz/getTankStats.ts index 2f75efd05..c8b2e7508 100644 --- a/src/core/blitz/getTankStats.ts +++ b/src/core/blitz/getTankStats.ts @@ -1,8 +1,8 @@ -import { BLITZ_SERVERS, BlitzServer } from '../../constants/servers.js'; -import { TanksStats } from '../../types/tanksStats.js'; -import { WARGAMING_APPLICATION_ID } from '../node/arguments.js'; -import throwError from '../node/throwError.js'; -import getWargamingResponse from './getWargamingResponse.js'; +import { BLITZ_SERVERS, BlitzServer } from '../../constants/servers'; +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) { const tankStats = await getWargamingResponse( diff --git a/src/core/blitz/getTreeType.ts b/src/core/blitz/getTreeType.ts index 6bedbe83e..bdbf303be 100644 --- a/src/core/blitz/getTreeType.ts +++ b/src/core/blitz/getTreeType.ts @@ -1,5 +1,5 @@ -import { TreeType } from '../../components/Tanks/index.js'; -import { tankopedia } from './tankopedia.js'; +import { TreeType } from '../../components/Tanks'; +import { tankopedia } from './tankopedia'; export default async function getTreeType(id: number) { const entry = (await tankopedia)[id]; diff --git a/src/core/blitz/getWN8Percentile.ts b/src/core/blitz/getWN8Percentile.ts index e153cad4e..b0ece4d77 100644 --- a/src/core/blitz/getWN8Percentile.ts +++ b/src/core/blitz/getWN8Percentile.ts @@ -1,4 +1,4 @@ -import { Percentile } from '../../constants/percentiles.js'; +import { Percentile } from '../../constants/percentiles'; export const WN8_PERCENTILES: [number, Percentile][] = [ [0, Percentile.VeryBad], diff --git a/src/core/blitz/getWargamingResponse.ts b/src/core/blitz/getWargamingResponse.ts index 78edbaa93..d0ce1d917 100644 --- a/src/core/blitz/getWargamingResponse.ts +++ b/src/core/blitz/getWargamingResponse.ts @@ -1,4 +1,4 @@ -import throwError from '../node/throwError.js'; +import throwError from '../node/throwError'; export type WargamingResponse = | { diff --git a/src/core/blitz/listClans.ts b/src/core/blitz/listClans.ts index d751e2de7..5c83d6c48 100644 --- a/src/core/blitz/listClans.ts +++ b/src/core/blitz/listClans.ts @@ -1,7 +1,7 @@ -import { BlitzServer } from '../../constants/servers.js'; -import { Clan, ClanList } from '../../types/clanList.js'; -import { WARGAMING_APPLICATION_ID } from '../node/arguments.js'; -import getWargamingResponse from './getWargamingResponse.js'; +import { BlitzServer } from '../../constants/servers'; +import { Clan, ClanList } from '../../types/clanList'; +import { WARGAMING_APPLICATION_ID } from '../node/arguments'; +import getWargamingResponse from './getWargamingResponse'; export type ClanListWithServer = (Clan & { server: 'com' | 'eu' | 'asia'; diff --git a/src/core/blitz/listPlayers.ts b/src/core/blitz/listPlayers.ts index 5820e59d5..4ee46bcd0 100644 --- a/src/core/blitz/listPlayers.ts +++ b/src/core/blitz/listPlayers.ts @@ -1,7 +1,7 @@ -import { BlitzServer } from '../../constants/servers.js'; -import { Account, AccountList } from '../../types/accountList.js'; -import { WARGAMING_APPLICATION_ID } from '../node/arguments.js'; -import getWargamingResponse from './getWargamingResponse.js'; +import { BlitzServer } from '../../constants/servers'; +import { Account, AccountList } from '../../types/accountList'; +import { WARGAMING_APPLICATION_ID } from '../node/arguments'; +import getWargamingResponse from './getWargamingResponse'; export type AccountListWithServer = (Account & { server: 'com' | 'eu' | 'asia'; diff --git a/src/core/blitz/resolveTankId.ts b/src/core/blitz/resolveTankId.ts index 76c74a824..a7bb5d8a2 100644 --- a/src/core/blitz/resolveTankId.ts +++ b/src/core/blitz/resolveTankId.ts @@ -1,6 +1,6 @@ import { go } from 'fuzzysort'; -import throwError from '../node/throwError.js'; -import { TANKS, tankopedia } from './tankopedia.js'; +import throwError from '../node/throwError'; +import { TANKS, tankopedia } from './tankopedia'; export default async function resolveTankId(tank: string) { const number = parseInt(tank); diff --git a/src/core/blitz/resolveTankName.ts b/src/core/blitz/resolveTankName.ts index 8d3405c71..6d3d38a8d 100644 --- a/src/core/blitz/resolveTankName.ts +++ b/src/core/blitz/resolveTankName.ts @@ -1,4 +1,4 @@ -import { tankopedia } from './tankopedia.js'; +import { tankopedia } from './tankopedia'; export default async function resolveTankName(tankId: number) { const tankopediaName = (await tankopedia)[tankId]?.name; diff --git a/src/core/blitz/sumStats.ts b/src/core/blitz/sumStats.ts index 31bf53d6f..160ddf593 100644 --- a/src/core/blitz/sumStats.ts +++ b/src/core/blitz/sumStats.ts @@ -1,5 +1,5 @@ -import { AllStats } from '../../types/accountInfo.js'; -import { emptyAllStats } from '../blitzstars/getDiffedTankStats.js'; +import { AllStats } from '../../types/accountInfo'; +import { emptyAllStats } from '../blitzstars/getDiffedTankStats'; export default function sumStats(allStatsCollection: AllStats[]) { return allStatsCollection.reduce((accumulated, current) => { diff --git a/src/core/blitzstars/getDiffedTankStats.ts b/src/core/blitzstars/getDiffedTankStats.ts index 208b816ad..bdbab3773 100644 --- a/src/core/blitzstars/getDiffedTankStats.ts +++ b/src/core/blitzstars/getDiffedTankStats.ts @@ -1,9 +1,9 @@ -import { BlitzServer } from '../../constants/servers.js'; -import { AllStats } from '../../types/accountInfo.js'; +import { BlitzServer } from '../../constants/servers'; +import { AllStats } from '../../types/accountInfo'; import getTankHistories, { TankHistories, TankHistoryRaw, -} from './getTankHistories.js'; +} from './getTankHistories'; export const emptyAllStats: AllStats = { battles: 0, diff --git a/src/core/blitzstars/getPeriodStart.ts b/src/core/blitzstars/getPeriodStart.ts index d1d820428..8357aab44 100644 --- a/src/core/blitzstars/getPeriodStart.ts +++ b/src/core/blitzstars/getPeriodStart.ts @@ -1,6 +1,6 @@ -import { BlitzServer } from '../../constants/servers.js'; -import { Period } from '../discord/addPeriodSubCommands.js'; -import getTimeDaysAgo from './getTimeDaysAgo.js'; +import { BlitzServer } from '../../constants/servers'; +import { Period } from '../discord/addPeriodSubCommands'; +import getTimeDaysAgo from './getTimeDaysAgo'; export default function getPeriodStart( server: BlitzServer, diff --git a/src/core/blitzstars/getPlayerHistories.ts b/src/core/blitzstars/getPlayerHistories.ts index fcbf625be..ac0419b93 100644 --- a/src/core/blitzstars/getPlayerHistories.ts +++ b/src/core/blitzstars/getPlayerHistories.ts @@ -1,14 +1,14 @@ -import { BlitzServer } from '../../constants/servers.js'; -import { AccountInfo, AllStats } from '../../types/accountInfo.js'; +import { BlitzServer } from '../../constants/servers'; +import { AccountInfo, AllStats } from '../../types/accountInfo'; import { GetHistoriesOptions, Histories, History, getHistoriesDefaultOptions, -} from '../../types/histories.js'; -import getWargamingResponse from '../blitz/getWargamingResponse.js'; -import { WARGAMING_APPLICATION_ID } from '../node/arguments.js'; -import { emptyAllStats } from './getDiffedTankStats.js'; +} from '../../types/histories'; +import getWargamingResponse from '../blitz/getWargamingResponse'; +import { WARGAMING_APPLICATION_ID } from '../node/arguments'; +import { emptyAllStats } from './getDiffedTankStats'; export interface PlayerHistoryRaw { clan: { clan_id: number; name: string; tag: string }; @@ -44,7 +44,7 @@ export default async function getPlayerHistories( ({ all: history.statistics.all, last_battle_time: history.last_battle_time, - } satisfies History), + }) satisfies History, ); let lastNonCompliantIndex = -1; let hasCompliedOnce = false; diff --git a/src/core/blitzstars/getTankHistories.ts b/src/core/blitzstars/getTankHistories.ts index b2a7aa713..e6fb78415 100644 --- a/src/core/blitzstars/getTankHistories.ts +++ b/src/core/blitzstars/getTankHistories.ts @@ -1,12 +1,12 @@ -import { BlitzServer } from '../../constants/servers.js'; +import { BlitzServer } from '../../constants/servers'; import { GetHistoriesOptions, Histories, History, getHistoriesDefaultOptions, -} from '../../types/histories.js'; -import getTankStats from '../blitz/getTankStats.js'; -import { emptyAllStats } from './getDiffedTankStats.js'; +} from '../../types/histories'; +import getTankStats from '../blitz/getTankStats'; +import { emptyAllStats } from './getDiffedTankStats'; export interface TankHistory extends History { tank_id: number; @@ -48,7 +48,7 @@ export default async function getTankHistories( all: history.all, last_battle_time: history.last_battle_time, tank_id: history.tank_id, - } satisfies TankHistory), + }) satisfies TankHistory, ); const compliantTanks: number[] = []; const lastBattles: Record = {}; diff --git a/src/core/blitzstars/getTimeDaysAgo.ts b/src/core/blitzstars/getTimeDaysAgo.ts index 357bca538..ff8452ec2 100644 --- a/src/core/blitzstars/getTimeDaysAgo.ts +++ b/src/core/blitzstars/getTimeDaysAgo.ts @@ -1,4 +1,4 @@ -import { BlitzServer } from '../../constants/servers.js'; +import { BlitzServer } from '../../constants/servers'; export const TIME_ZONE_MAPPINGS: Record = { com: -5, // Central North American Time diff --git a/src/core/blitzstars/playerAverage.ts b/src/core/blitzstars/playerAverage.ts index 4f79f77af..b9b750957 100644 --- a/src/core/blitzstars/playerAverage.ts +++ b/src/core/blitzstars/playerAverage.ts @@ -1,6 +1,6 @@ -import sumStats from '../blitz/sumStats.js'; -import { emptyAllStats } from './getDiffedTankStats.js'; -import { tankAverages } from './tankAverages.js'; +import sumStats from '../blitz/sumStats'; +import { emptyAllStats } from './getDiffedTankStats'; +import { tankAverages } from './tankAverages'; console.log('Calculating player average...'); export const playerAverage = Object.entries(await tankAverages).reduce( diff --git a/src/core/blitzstars/tankAverages.ts b/src/core/blitzstars/tankAverages.ts index 84733e336..c36b554ca 100644 --- a/src/core/blitzstars/tankAverages.ts +++ b/src/core/blitzstars/tankAverages.ts @@ -1,4 +1,4 @@ -import { AllStats } from '../../types/accountInfo.js'; +import { AllStats } from '../../types/accountInfo'; export interface SpecialStats { winrate: number; diff --git a/src/core/discord/addPeriodSubCommands.ts b/src/core/discord/addPeriodSubCommands.ts index 74fd61087..35d7a4dda 100644 --- a/src/core/discord/addPeriodSubCommands.ts +++ b/src/core/discord/addPeriodSubCommands.ts @@ -2,7 +2,7 @@ import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, } from 'discord.js'; -import { PERIOD_NAMES } from '../discord/resolvePeriodFromCommand.js'; +import { PERIOD_NAMES } from '../discord/resolvePeriodFromCommand'; export type Period = 'today' | '30' | '60' | '90' | 'career' | 'custom'; diff --git a/src/core/discord/addServerChoices.ts b/src/core/discord/addServerChoices.ts index 5c6ad5def..e3f806aa9 100644 --- a/src/core/discord/addServerChoices.ts +++ b/src/core/discord/addServerChoices.ts @@ -1,5 +1,5 @@ import { SlashCommandStringOption } from 'discord.js'; -import { BLITZ_SERVERS } from '../../constants/servers.js'; +import { BLITZ_SERVERS } from '../../constants/servers'; export default function addServerChoices(option: SlashCommandStringOption) { return option diff --git a/src/core/discord/addStatTypeSubCommandGroups.ts b/src/core/discord/addStatTypeSubCommandGroups.ts index a5657db10..66fe7f586 100644 --- a/src/core/discord/addStatTypeSubCommandGroups.ts +++ b/src/core/discord/addStatTypeSubCommandGroups.ts @@ -1,7 +1,7 @@ import { SlashCommandBuilder } from 'discord.js'; -import addPeriodSubCommands from './addPeriodSubCommands.js'; -import addTankChoices from './addTankChoices.js'; -import addUsernameChoices from './addUsernameChoices.js'; +import addPeriodSubCommands from './addPeriodSubCommands'; +import addTankChoices from './addTankChoices'; +import addUsernameChoices from './addUsernameChoices'; export default function addStatTypeSubCommandGroups( option: SlashCommandBuilder, diff --git a/src/core/discord/autocompleteClan.ts b/src/core/discord/autocompleteClan.ts index 78c7df143..fb5296ddc 100644 --- a/src/core/discord/autocompleteClan.ts +++ b/src/core/discord/autocompleteClan.ts @@ -3,8 +3,8 @@ import { AutocompleteInteraction, CacheType, } from 'discord.js'; -import { BLITZ_SERVERS } from '../../constants/servers.js'; -import listClans from '../blitz/listClans.js'; +import { BLITZ_SERVERS } from '../../constants/servers'; +import listClans from '../blitz/listClans'; export default async function autocompleteClan( interaction: AutocompleteInteraction, @@ -20,7 +20,7 @@ export default async function autocompleteClan( ({ name: `${player.name} (${BLITZ_SERVERS[player.server]})`, value: `${player.server}/${player.clan_id}`, - } satisfies ApplicationCommandOptionChoiceData), + }) satisfies ApplicationCommandOptionChoiceData, ) : [], ); diff --git a/src/core/discord/autocompleteTanks.ts b/src/core/discord/autocompleteTanks.ts index ec75c052c..a7a1cdbaa 100644 --- a/src/core/discord/autocompleteTanks.ts +++ b/src/core/discord/autocompleteTanks.ts @@ -4,8 +4,8 @@ import { CacheType, } from 'discord.js'; import { go } from 'fuzzysort'; -import resolveTankName from '../blitz/resolveTankName.js'; -import { TANKS } from '../blitz/tankopedia.js'; +import resolveTankName from '../blitz/resolveTankName'; +import { TANKS } from '../blitz/tankopedia'; export default async function autocompleteTanks( interaction: AutocompleteInteraction, @@ -16,14 +16,17 @@ export default async function autocompleteTanks( await interaction.respond( focusedOption.value ? await Promise.all( - go(focusedOption.value, await TANKS, { keys: ['name'], limit: 10 }).map( + go(focusedOption.value, await TANKS, { + keys: ['name'], + limit: 10, + }).map( async (item) => ({ name: item.obj.name ? item.obj.name : await resolveTankName(item.obj.tank_id), value: `${item.obj.tank_id}`, - } satisfies ApplicationCommandOptionChoiceData), + }) satisfies ApplicationCommandOptionChoiceData, ), ) : [], diff --git a/src/core/discord/autocompleteUsername.ts b/src/core/discord/autocompleteUsername.ts index 871f424f2..2ee5b3464 100644 --- a/src/core/discord/autocompleteUsername.ts +++ b/src/core/discord/autocompleteUsername.ts @@ -3,8 +3,8 @@ import { AutocompleteInteraction, CacheType, } from 'discord.js'; -import { BLITZ_SERVERS } from '../../constants/servers.js'; -import listPlayers from '../blitz/listPlayers.js'; +import { BLITZ_SERVERS } from '../../constants/servers'; +import listPlayers from '../blitz/listPlayers'; export default async function autocompleteUsername( interaction: AutocompleteInteraction, @@ -21,7 +21,7 @@ export default async function autocompleteUsername( ({ name: `${player.nickname} (${BLITZ_SERVERS[player.server]})`, value: `${player.server}/${player.account_id}`, - } satisfies ApplicationCommandOptionChoiceData), + }) satisfies ApplicationCommandOptionChoiceData, ) : [], ); diff --git a/src/core/discord/embedInfo.ts b/src/core/discord/embedInfo.ts index a188a1643..75ac86c80 100644 --- a/src/core/discord/embedInfo.ts +++ b/src/core/discord/embedInfo.ts @@ -1,5 +1,5 @@ import { EmbedBuilder } from 'discord.js'; -import { ACCENT_COLOR } from '../../constants/colors.js'; +import { ACCENT_COLOR } from '../../constants/colors'; export default function embedInfo(title: string, description: string) { const embed = new EmbedBuilder() diff --git a/src/core/discord/embedNegative.ts b/src/core/discord/embedNegative.ts index 54e11ab8b..35704b20e 100644 --- a/src/core/discord/embedNegative.ts +++ b/src/core/discord/embedNegative.ts @@ -1,5 +1,5 @@ import { EmbedBuilder } from 'discord.js'; -import { NEGATIVE_COLOR } from '../../constants/colors.js'; +import { NEGATIVE_COLOR } from '../../constants/colors'; export default function embedNegative(title: string, description: string) { return new EmbedBuilder() diff --git a/src/core/discord/embedPositive.ts b/src/core/discord/embedPositive.ts index c9067d818..47174a0d1 100644 --- a/src/core/discord/embedPositive.ts +++ b/src/core/discord/embedPositive.ts @@ -1,5 +1,5 @@ import { EmbedBuilder } from 'discord.js'; -import { POSITIVE_COLOR } from '../../constants/colors.js'; +import { POSITIVE_COLOR } from '../../constants/colors'; export default function embedPositive(title: string, description: string) { return new EmbedBuilder() diff --git a/src/core/discord/embedWarning.ts b/src/core/discord/embedWarning.ts index 45ee01909..3148f7a7a 100644 --- a/src/core/discord/embedWarning.ts +++ b/src/core/discord/embedWarning.ts @@ -1,5 +1,5 @@ import { EmbedBuilder } from 'discord.js'; -import { WARNING_COLOR } from '../../constants/colors.js'; +import { WARNING_COLOR } from '../../constants/colors'; export default function embedWarning(title: string, description: string) { return new EmbedBuilder() diff --git a/src/core/discord/normalizeInteractionReturnable.ts b/src/core/discord/normalizeInteractionReturnable.ts index 828812eb2..3f354735b 100644 --- a/src/core/discord/normalizeInteractionReturnable.ts +++ b/src/core/discord/normalizeInteractionReturnable.ts @@ -4,8 +4,8 @@ import { EmbedBuilder, InteractionEditReplyOptions, } from 'discord.js'; -import { InteractionReturnable } from '../../events/interactionCreate/index.js'; -import jsxToPng from '../node/jsxToPng.js'; +import { InteractionReturnable } from '../../events/interactionCreate'; +import jsxToPng from '../node/jsxToPng'; export default async function normalizeInteractionReturnable( returnable: InteractionReturnable, diff --git a/src/core/discord/resolvePeriodFromButton.ts b/src/core/discord/resolvePeriodFromButton.ts index 823780c75..0c31e65e4 100644 --- a/src/core/discord/resolvePeriodFromButton.ts +++ b/src/core/discord/resolvePeriodFromButton.ts @@ -1,7 +1,7 @@ import { ButtonInteraction, CacheType } from 'discord.js'; -import { CYCLIC_API } from '../../constants/cyclic.js'; -import { BlitzServer } from '../../constants/servers.js'; -import resolvePeriodFromURL from '../express/resolvePeriodFromURL.js'; +import { CYCLIC_API } from '../../constants/cyclic'; +import { BlitzServer } from '../../constants/servers'; +import resolvePeriodFromURL from '../express/resolvePeriodFromURL'; export default function resolvePeriodFromButton( server: BlitzServer, diff --git a/src/core/discord/resolvePeriodFromCommand.ts b/src/core/discord/resolvePeriodFromCommand.ts index c3d8816d6..6672f41fb 100644 --- a/src/core/discord/resolvePeriodFromCommand.ts +++ b/src/core/discord/resolvePeriodFromCommand.ts @@ -1,9 +1,9 @@ import { CacheType, ChatInputCommandInteraction } from 'discord.js'; -import { BlitzServer } from '../../constants/servers.js'; -import getPeriodNow from '../blitzstars/getPeriodNow.js'; -import getPeriodStart from '../blitzstars/getPeriodStart.js'; -import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo.js'; -import { Period } from '../discord/addPeriodSubCommands.js'; +import { BlitzServer } from '../../constants/servers'; +import getPeriodNow from '../blitzstars/getPeriodNow'; +import getPeriodStart from '../blitzstars/getPeriodStart'; +import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo'; +import { Period } from '../discord/addPeriodSubCommands'; export const PERIOD_NAMES: Record = { today: "Today's statistics", diff --git a/src/core/discord/resolvePlayerFromButton.ts b/src/core/discord/resolvePlayerFromButton.ts index c6b956359..eb469366b 100644 --- a/src/core/discord/resolvePlayerFromButton.ts +++ b/src/core/discord/resolvePlayerFromButton.ts @@ -1,6 +1,6 @@ import { ButtonInteraction, CacheType } from 'discord.js'; -import { CYCLIC_API } from '../../constants/cyclic.js'; -import resolvePlayerFromURL from '../express/resolvePlayerFromURL.js'; +import { CYCLIC_API } from '../../constants/cyclic'; +import resolvePlayerFromURL from '../express/resolvePlayerFromURL'; export default async function resolvePlayerFromButton( interaction: ButtonInteraction, diff --git a/src/core/discord/resolvePlayerFromCommand.ts b/src/core/discord/resolvePlayerFromCommand.ts index 084b8c52f..7c30bfa27 100644 --- a/src/core/discord/resolvePlayerFromCommand.ts +++ b/src/core/discord/resolvePlayerFromCommand.ts @@ -1,9 +1,9 @@ import { CacheType, ChatInputCommandInteraction } from 'discord.js'; -import { BlitzServer } from '../../constants/servers.js'; +import { BlitzServer } from '../../constants/servers'; import listPlayers, { usernamePatternWithoutPosition, -} from '../blitz/listPlayers.js'; -import throwError from '../node/throwError.js'; +} from '../blitz/listPlayers'; +import throwError from '../node/throwError'; export const serverAndIdPattern = /(com|eu|asia)\/[0-9]+/; diff --git a/src/core/express/normalizeRouteReturnable.ts b/src/core/express/normalizeRouteReturnable.ts index f630232da..8f3ecfd1c 100644 --- a/src/core/express/normalizeRouteReturnable.ts +++ b/src/core/express/normalizeRouteReturnable.ts @@ -1,5 +1,5 @@ -import { RouteReturnable } from '../../server.js'; -import jsxToSvg from '../node/jsxToSvg.js'; +import { RouteReturnable } from '../../server'; +import jsxToSvg from '../node/jsxToSvg'; export default async function normalizeRouteReturnable( returnable: RouteReturnable, diff --git a/src/core/express/resolvePeriodFromRequest.ts b/src/core/express/resolvePeriodFromRequest.ts index 2350d09e0..b0e964ad8 100644 --- a/src/core/express/resolvePeriodFromRequest.ts +++ b/src/core/express/resolvePeriodFromRequest.ts @@ -1,7 +1,7 @@ import { Request } from 'express'; -import { CYCLIC_API } from '../../constants/cyclic.js'; -import { BlitzServer } from '../../constants/servers.js'; -import resolvePeriodFromURL from './resolvePeriodFromURL.js'; +import { CYCLIC_API } from '../../constants/cyclic'; +import { BlitzServer } from '../../constants/servers'; +import resolvePeriodFromURL from './resolvePeriodFromURL'; export default function resolvePeriodFromRequest( server: BlitzServer, diff --git a/src/core/express/resolvePeriodFromURL.ts b/src/core/express/resolvePeriodFromURL.ts index e490a15aa..d478126c6 100644 --- a/src/core/express/resolvePeriodFromURL.ts +++ b/src/core/express/resolvePeriodFromURL.ts @@ -1,13 +1,13 @@ -import { BlitzServer } from '../../constants/servers.js'; -import getPeriodNow from '../blitzstars/getPeriodNow.js'; -import getPeriodStart from '../blitzstars/getPeriodStart.js'; -import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo.js'; -import { Period } from '../discord/addPeriodSubCommands.js'; +import { BlitzServer } from '../../constants/servers'; +import getPeriodNow from '../blitzstars/getPeriodNow'; +import getPeriodStart from '../blitzstars/getPeriodStart'; +import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo'; +import { Period } from '../discord/addPeriodSubCommands'; import { EVOLUTION_PERIOD_NAMES, PERIOD_NAMES, ResolvedPeriod, -} from '../discord/resolvePeriodFromCommand.js'; +} from '../discord/resolvePeriodFromCommand'; export default function resolvePeriodFromURL( server: BlitzServer, diff --git a/src/core/express/resolvePlayerFromRequest.ts b/src/core/express/resolvePlayerFromRequest.ts index 2fe5bd578..600c39fdb 100644 --- a/src/core/express/resolvePlayerFromRequest.ts +++ b/src/core/express/resolvePlayerFromRequest.ts @@ -1,6 +1,6 @@ import { Request } from 'express'; -import { CYCLIC_API } from '../../constants/cyclic.js'; -import resolvePlayerFromURL from './resolvePlayerFromURL.js'; +import { CYCLIC_API } from '../../constants/cyclic'; +import resolvePlayerFromURL from './resolvePlayerFromURL'; export default function resolvePlayerFromRequest(request: Request) { return resolvePlayerFromURL(`${CYCLIC_API}${request.originalUrl}`); diff --git a/src/core/express/resolvePlayerFromURL.ts b/src/core/express/resolvePlayerFromURL.ts index 81608ab13..983fa11b8 100644 --- a/src/core/express/resolvePlayerFromURL.ts +++ b/src/core/express/resolvePlayerFromURL.ts @@ -1,5 +1,5 @@ -import { BlitzServer } from '../../constants/servers.js'; -import { ResolvedPlayer } from '../discord/resolvePlayerFromCommand.js'; +import { BlitzServer } from '../../constants/servers'; +import { ResolvedPlayer } from '../discord/resolvePlayerFromCommand'; export default function resolvePlayerFromURL(urlString: string) { const url = new URL(urlString); diff --git a/src/core/node/getClientId.ts b/src/core/node/getClientId.ts index bbc2506ed..4f292d07e 100644 --- a/src/core/node/getClientId.ts +++ b/src/core/node/getClientId.ts @@ -1,5 +1,5 @@ import discord from '../../../discord.json' assert { type: 'json' }; -import isDev from './isDev.js'; +import isDev from './isDev'; export default function getClientId() { return isDev() ? discord.client_id_dev : discord.client_id; diff --git a/src/core/node/jsxToPng.ts b/src/core/node/jsxToPng.ts index e48d3b1f5..b558dcd2b 100644 --- a/src/core/node/jsxToPng.ts +++ b/src/core/node/jsxToPng.ts @@ -1,5 +1,5 @@ -import jsxToSvg from './jsxToSvg.js'; -import svgToPng from './svgToPng.js'; +import jsxToSvg from './jsxToSvg'; +import svgToPng from './svgToPng'; export default async function jsxToPng(jsx: JSX.Element) { const svg = await jsxToSvg(jsx); diff --git a/src/core/node/svgToPng.ts b/src/core/node/svgToPng.ts index 3a221097d..601c8648c 100644 --- a/src/core/node/svgToPng.ts +++ b/src/core/node/svgToPng.ts @@ -1,5 +1,5 @@ -import { Resvg } from "@resvg/resvg-js"; +import { Resvg } from '@resvg/resvg-js'; export default function svgToPng(svg: string) { - return new Resvg(svg).render().asPng() -} \ No newline at end of file + return new Resvg(svg).render().asPng(); +} diff --git a/src/events/error.ts b/src/events/error.ts index 8dec386de..c4104b5ff 100644 --- a/src/events/error.ts +++ b/src/events/error.ts @@ -1,8 +1,8 @@ import { EmbedBuilder, TextChannel } from 'discord.js'; import discord from '../../discord.json' assert { type: 'json' }; -import { client } from '../bot.js'; -import { NEGATIVE_COLOR } from '../constants/colors.js'; -import isDev from '../core/node/isDev.js'; +import { client } from '../bot'; +import { NEGATIVE_COLOR } from '../constants/colors'; +import isDev from '../core/node/isDev'; const PROCESS_ERROR_EVENTS = ['uncaughtException']; const CLIENT_ERROR_EVENTS = ['error']; diff --git a/src/events/guildMemberAdd.ts b/src/events/guildMemberAdd.ts index 60b0abb3a..4e57ef9d9 100644 --- a/src/events/guildMemberAdd.ts +++ b/src/events/guildMemberAdd.ts @@ -1,6 +1,6 @@ import { EmbedBuilder, GuildMember, TextChannel } from 'discord.js'; import discord from '../../discord.json' assert { type: 'json' }; -import { ACCENT_COLOR } from '../constants/colors.js'; +import { ACCENT_COLOR } from '../constants/colors'; export default async function (member: GuildMember) { if (member.guild.id === discord.sklld_guild_id) { diff --git a/src/events/interactionCreate/handlers/autocomplete.ts b/src/events/interactionCreate/handlers/autocomplete.ts index 0a9383bed..af4b81bed 100644 --- a/src/events/interactionCreate/handlers/autocomplete.ts +++ b/src/events/interactionCreate/handlers/autocomplete.ts @@ -1,5 +1,5 @@ import { AutocompleteInteraction, CacheType } from 'discord.js'; -import { commands } from '../index.js'; +import { commands } from '..'; export default function handleAutocomplete( interaction: AutocompleteInteraction, diff --git a/src/events/interactionCreate/handlers/button.tsx b/src/events/interactionCreate/handlers/button.tsx index 657a0bcc8..7fc55ae21 100644 --- a/src/events/interactionCreate/handlers/button.tsx +++ b/src/events/interactionCreate/handlers/button.tsx @@ -1,8 +1,8 @@ import { ButtonInteraction, CacheType } from 'discord.js'; -import { CYCLIC_API } from '../../../constants/cyclic.js'; -import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable.js'; -import throwError from '../../../core/node/throwError.js'; -import { commands } from '../index.js'; +import { commands } from '..'; +import { CYCLIC_API } from '../../../constants/cyclic'; +import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable'; +import throwError from '../../../core/node/throwError'; export default async function handleButton( interaction: ButtonInteraction, diff --git a/src/events/interactionCreate/handlers/chatInputCommand.ts b/src/events/interactionCreate/handlers/chatInputCommand.ts index 3422b8121..f7b1a855d 100644 --- a/src/events/interactionCreate/handlers/chatInputCommand.ts +++ b/src/events/interactionCreate/handlers/chatInputCommand.ts @@ -5,12 +5,12 @@ import { CacheType, ChatInputCommandInteraction, } from 'discord.js'; -import embedNegative from '../../../core/discord/embedNegative.js'; -import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable.js'; -import embedWarning from '../../../core/discord/embedWarning.js'; -import { psa } from '../../../core/discord/psa.js'; -import { handleError } from '../../error.js'; -import { commands } from '../index.js'; +import { commands } from '..'; +import embedNegative from '../../../core/discord/embedNegative'; +import embedWarning from '../../../core/discord/embedWarning'; +import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable'; +import { psa } from '../../../core/discord/psa'; +import { handleError } from '../../error'; export default async function handleChatInputCommand( interaction: ChatInputCommandInteraction, diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 952155d16..af2ba8d27 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -13,28 +13,28 @@ import { SlashCommandSubcommandsOnlyBuilder, } from 'discord.js'; import discord from '../../../discord.json' assert { type: 'json' }; -import { debugCommand } from '../../commands/debug.js'; -import { eligibleCommand } from '../../commands/eligible.js'; -import { evolutionCommand } from '../../commands/evolution.js'; -import { fullStatsCommand } from '../../commands/fullStats.js'; -import { helpCommand } from '../../commands/help.js'; -import { inactiveCommand } from '../../commands/inactive.js'; -import { ownedTanksCommand } from '../../commands/ownedTanks.js'; -import { pingCommand } from '../../commands/ping.js'; -import { playerAchievementsCommand } from '../../commands/playerAchievements.js'; -import { playerInfoCommand } from '../../commands/playerInfo.js'; -import { searchClansCommand } from '../../commands/searchClans.js'; -import { searchPlayersCommand } from '../../commands/searchPlayers.js'; -import { searchTanksCommand } from '../../commands/searchTanks.js'; -import { statsCommand } from '../../commands/stats.js'; -import { todayCommand } from '../../commands/today.js'; -import { verifyCommand } from '../../commands/verify.js'; -import { DISCORD_TOKEN } from '../../core/node/arguments.js'; -import getClientId from '../../core/node/getClientId.js'; -import isDev from '../../core/node/isDev.js'; -import handleAutocomplete from './handlers/autocomplete.js'; -import handleButton from './handlers/button.js'; -import handleChatInputCommand from './handlers/chatInputCommand.js'; +import { debugCommand } from '../../commands/debug'; +import { eligibleCommand } from '../../commands/eligible'; +import { evolutionCommand } from '../../commands/evolution'; +import { fullStatsCommand } from '../../commands/fullStats'; +import { helpCommand } from '../../commands/help'; +import { inactiveCommand } from '../../commands/inactive'; +import { ownedTanksCommand } from '../../commands/ownedTanks'; +import { pingCommand } from '../../commands/ping'; +import { playerAchievementsCommand } from '../../commands/playerAchievements'; +import { playerInfoCommand } from '../../commands/playerInfo'; +import { searchClansCommand } from '../../commands/searchClans'; +import { searchPlayersCommand } from '../../commands/searchPlayers'; +import { searchTanksCommand } from '../../commands/searchTanks'; +import { statsCommand } from '../../commands/stats'; +import { todayCommand } from '../../commands/today'; +import { verifyCommand } from '../../commands/verify'; +import { DISCORD_TOKEN } from '../../core/node/arguments'; +import getClientId from '../../core/node/getClientId'; +import isDev from '../../core/node/isDev'; +import handleAutocomplete from './handlers/autocomplete'; +import handleButton from './handlers/button'; +import handleChatInputCommand from './handlers/chatInputCommand'; export type InteractionRawReturnable = | string diff --git a/src/events/ready.ts b/src/events/ready.ts index e84016295..cf6996d04 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -1,5 +1,5 @@ import { Client } from 'discord.js'; -import isDev from '../core/node/isDev.js'; +import isDev from '../core/node/isDev'; export default function ready(client: Client) { console.log( diff --git a/src/renderers/evolution.tsx b/src/renderers/evolution.tsx index e54417630..19d4f85e6 100644 --- a/src/renderers/evolution.tsx +++ b/src/renderers/evolution.tsx @@ -1,21 +1,21 @@ -import * as Graph from '../components/Graph/index.js'; -import NoData, { NoDataType } from '../components/NoData.js'; -import PoweredBy, { PoweredByType } from '../components/PoweredBy.js'; -import TitleBar from '../components/TitleBar.js'; -import Wrapper from '../components/Wrapper.js'; -import { BLITZ_SERVERS } from '../constants/servers.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import resolveTankName from '../core/blitz/resolveTankName.js'; -import { tankopedia } from '../core/blitz/tankopedia.js'; -import getPlayerHistories from '../core/blitzstars/getPlayerHistories.js'; -import getTankHistories from '../core/blitzstars/getTankHistories.js'; -import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand.js'; -import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { AccountInfo } from '../types/accountInfo.js'; -import { Histories } from '../types/histories.js'; -import { PlayerClanData } from '../types/playerClanData.js'; -import { StatType } from './fullStats.js'; +import * as Graph from '../components/Graph'; +import NoData, { NoDataType } from '../components/NoData'; +import PoweredBy, { PoweredByType } from '../components/PoweredBy'; +import TitleBar from '../components/TitleBar'; +import Wrapper from '../components/Wrapper'; +import { BLITZ_SERVERS } from '../constants/servers'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import resolveTankName from '../core/blitz/resolveTankName'; +import { tankopedia } from '../core/blitz/tankopedia'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { AccountInfo } from '../types/accountInfo'; +import { Histories } from '../types/histories'; +import { PlayerClanData } from '../types/playerClanData'; +import { StatType } from './fullStats'; export default async function evolution( type: Type, diff --git a/src/renderers/fullStats.tsx b/src/renderers/fullStats.tsx index a9ecae06e..1a2b20d2d 100644 --- a/src/renderers/fullStats.tsx +++ b/src/renderers/fullStats.tsx @@ -1,27 +1,27 @@ -import GenericAllStats from '../components/GenericAllStats/index.js'; -import NoData, { NoDataType } from '../components/NoData.js'; -import PoweredBy, { PoweredByType } from '../components/PoweredBy.js'; -import TierWeights, { TierWeightsRecord } from '../components/TierWeights.js'; -import TitleBar from '../components/TitleBar.js'; -import Wrapper from '../components/Wrapper.js'; -import { BLITZ_SERVERS } from '../constants/servers.js'; -import calculateWN8 from '../core/blitz/calculateWN8.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import resolveTankName from '../core/blitz/resolveTankName.js'; -import sumStats from '../core/blitz/sumStats.js'; -import { Tier, tankopedia } from '../core/blitz/tankopedia.js'; -import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats.js'; -import { tankAverages } from '../core/blitzstars/tankAverages.js'; -import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand.js'; -import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; +import GenericAllStats from '../components/GenericAllStats'; +import NoData, { NoDataType } from '../components/NoData'; +import PoweredBy, { PoweredByType } from '../components/PoweredBy'; +import TierWeights, { TierWeightsRecord } from '../components/TierWeights'; +import TitleBar from '../components/TitleBar'; +import Wrapper from '../components/Wrapper'; +import { BLITZ_SERVERS } from '../constants/servers'; +import calculateWN8 from '../core/blitz/calculateWN8'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import resolveTankName from '../core/blitz/resolveTankName'; +import sumStats from '../core/blitz/sumStats'; +import { Tier, tankopedia } from '../core/blitz/tankopedia'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; import { AccountInfo, AllStats, SupplementaryStats, -} from '../types/accountInfo.js'; -import { PlayerClanData } from '../types/playerClanData.js'; -import { PossiblyPromise } from '../types/possiblyPromise.js'; +} from '../types/accountInfo'; +import { PlayerClanData } from '../types/playerClanData'; +import { PossiblyPromise } from '../types/possiblyPromise'; export type StatType = 'player' | 'tank'; diff --git a/src/renderers/stats.tsx b/src/renderers/stats.tsx index 5756da28a..9fe5e2629 100644 --- a/src/renderers/stats.tsx +++ b/src/renderers/stats.tsx @@ -1,28 +1,28 @@ -import AllStatsOverview from '../components/AllStatsOverview/index.js'; -import NoData, { NoDataType } from '../components/NoData.js'; -import PoweredBy, { PoweredByType } from '../components/PoweredBy.js'; -import { TierWeightsRecord } from '../components/TierWeights.js'; -import TitleBar from '../components/TitleBar.js'; -import Wrapper from '../components/Wrapper.js'; -import { BLITZ_SERVERS } from '../constants/servers.js'; -import calculateWN8 from '../core/blitz/calculateWN8.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import resolveTankName from '../core/blitz/resolveTankName.js'; -import sumStats from '../core/blitz/sumStats.js'; -import { Tier, tankopedia } from '../core/blitz/tankopedia.js'; -import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats.js'; -import { tankAverages } from '../core/blitzstars/tankAverages.js'; -import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand.js'; -import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { theme } from '../stitches.config.js'; +import AllStatsOverview from '../components/AllStatsOverview'; +import NoData, { NoDataType } from '../components/NoData'; +import PoweredBy, { PoweredByType } from '../components/PoweredBy'; +import { TierWeightsRecord } from '../components/TierWeights'; +import TitleBar from '../components/TitleBar'; +import Wrapper from '../components/Wrapper'; +import { BLITZ_SERVERS } from '../constants/servers'; +import calculateWN8 from '../core/blitz/calculateWN8'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import resolveTankName from '../core/blitz/resolveTankName'; +import sumStats from '../core/blitz/sumStats'; +import { Tier, tankopedia } from '../core/blitz/tankopedia'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { theme } from '../stitches.config'; import { AccountInfo, AllStats, SupplementaryStats, -} from '../types/accountInfo.js'; -import { PlayerClanData } from '../types/playerClanData.js'; -import { PossiblyPromise } from '../types/possiblyPromise.js'; +} from '../types/accountInfo'; +import { PlayerClanData } from '../types/playerClanData'; +import { PossiblyPromise } from '../types/possiblyPromise'; export type StatType = 'player' | 'tank'; diff --git a/src/renderers/today.tsx b/src/renderers/today.tsx index 9a0c96839..24028604f 100644 --- a/src/renderers/today.tsx +++ b/src/renderers/today.tsx @@ -1,24 +1,24 @@ -import * as Breakdown from '../components/Breakdown/index.js'; -import NoData, { NoDataType } from '../components/NoData.js'; -import PoweredBy, { PoweredByType } from '../components/PoweredBy.js'; -import TitleBar from '../components/TitleBar.js'; -import Wrapper from '../components/Wrapper.js'; -import { BLITZ_SERVERS } from '../constants/servers.js'; -import calculateWN8 from '../core/blitz/calculateWN8.js'; -import getTankStats from '../core/blitz/getTankStats.js'; -import getWargamingResponse from '../core/blitz/getWargamingResponse.js'; -import resolveTankName from '../core/blitz/resolveTankName.js'; -import sumStats from '../core/blitz/sumStats.js'; -import { tankopedia } from '../core/blitz/tankopedia.js'; -import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats.js'; -import getPeriodNow from '../core/blitzstars/getPeriodNow.js'; -import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo.js'; -import { tankAverages } from '../core/blitzstars/tankAverages.js'; -import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand.js'; -import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; -import { AccountInfo, AllStats } from '../types/accountInfo.js'; -import { PlayerClanData } from '../types/playerClanData.js'; -import { PossiblyPromise } from '../types/possiblyPromise.js'; +import * as Breakdown from '../components/Breakdown'; +import NoData, { NoDataType } from '../components/NoData'; +import PoweredBy, { PoweredByType } from '../components/PoweredBy'; +import TitleBar from '../components/TitleBar'; +import Wrapper from '../components/Wrapper'; +import { BLITZ_SERVERS } from '../constants/servers'; +import calculateWN8 from '../core/blitz/calculateWN8'; +import getTankStats from '../core/blitz/getTankStats'; +import getWargamingResponse from '../core/blitz/getWargamingResponse'; +import resolveTankName from '../core/blitz/resolveTankName'; +import sumStats from '../core/blitz/sumStats'; +import { tankopedia } from '../core/blitz/tankopedia'; +import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats'; +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 { WARGAMING_APPLICATION_ID } from '../core/node/arguments'; +import { AccountInfo, AllStats } from '../types/accountInfo'; +import { PlayerClanData } from '../types/playerClanData'; +import { PossiblyPromise } from '../types/possiblyPromise'; export default async function today( { server, id }: ResolvedPlayer, diff --git a/src/routes/stats.tsx b/src/routes/stats.tsx index f67840232..b9f79752a 100644 --- a/src/routes/stats.tsx +++ b/src/routes/stats.tsx @@ -1,7 +1,7 @@ -import resolvePeriodFromRequest from '../core/express/resolvePeriodFromRequest.js'; -import resolvePlayerFromRequest from '../core/express/resolvePlayerFromRequest.js'; -import stats, { StatType } from '../renderers/stats.js'; -import { RouteRegistry } from '../server.js'; +import resolvePeriodFromRequest from '../core/express/resolvePeriodFromRequest'; +import resolvePlayerFromRequest from '../core/express/resolvePlayerFromRequest'; +import stats, { StatType } from '../renderers/stats'; +import { RouteRegistry } from '../server'; export const statsRoute: RouteRegistry = { route: '/stats/:type/:period', diff --git a/src/routes/today.tsx b/src/routes/today.tsx index 257c79473..8a5f193ed 100644 --- a/src/routes/today.tsx +++ b/src/routes/today.tsx @@ -1,6 +1,6 @@ -import resolvePlayerFromRequest from '../core/express/resolvePlayerFromRequest.js'; -import today from '../renderers/today.js'; -import { RouteRegistry } from '../server.js'; +import resolvePlayerFromRequest from '../core/express/resolvePlayerFromRequest'; +import today from '../renderers/today'; +import { RouteRegistry } from '../server'; export const todayRoute: RouteRegistry = { route: '/today', diff --git a/src/server.ts b/src/server.ts index 2db9ec1c1..998ff4d8f 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,10 +1,10 @@ import express, { Request, Response } from 'express'; -import normalizeRouteReturnable from './core/express/normalizeRouteReturnable.js'; -import withAutoRefresh from './core/express/withAutoRefresh.js'; -import isDev from './core/node/isDev.js'; -import { Registry } from './events/interactionCreate/index.js'; -import { statsRoute } from './routes/stats.js'; -import { todayRoute } from './routes/today.js'; +import normalizeRouteReturnable from './core/express/normalizeRouteReturnable'; +import withAutoRefresh from './core/express/withAutoRefresh'; +import isDev from './core/node/isDev'; +import { Registry } from './events/interactionCreate'; +import { statsRoute } from './routes/stats'; +import { todayRoute } from './routes/today'; export type RouteReturnable = JSX.Element | Promise; diff --git a/src/types/clanInfo.ts b/src/types/clanInfo.ts index db1f412f6..7ac8e8d5e 100644 --- a/src/types/clanInfo.ts +++ b/src/types/clanInfo.ts @@ -1,28 +1,30 @@ export interface ClanInfo { - [clanId:number]:{recruiting_options: { - vehicles_level: number; - wins_ratio: number; - average_battles_per_day: number; - battles: number; - average_damage: number; + [clanId: number]: { + recruiting_options: { + vehicles_level: number; + wins_ratio: number; + average_battles_per_day: number; + battles: number; + average_damage: number; + }; + members_count: number; + name: string; + creator_name: string; + clan_id: number; + created_at: number; + updated_at: number; + leader_name: string; + members_ids: number[]; + recruiting_policy: string; + tag: string; + is_clan_disbanded: boolean; + old_name: string; + emblem_set_id: number; + creator_id: number; + motto: string; + renamed_at: number; + old_tag: null; + leader_id: number; + description: string; }; - members_count: number; - name: string; - creator_name: string; - clan_id: number; - created_at: number; - updated_at: number; - leader_name: string; - members_ids: number[]; - recruiting_policy: string; - tag: string; - is_clan_disbanded: boolean; - old_name: string; - emblem_set_id: number; - creator_id: number; - motto: string; - renamed_at: number; - old_tag: null; - leader_id: number; - description: string;} } diff --git a/src/types/histories.ts b/src/types/histories.ts index 9258831f7..d2c5ae8be 100644 --- a/src/types/histories.ts +++ b/src/types/histories.ts @@ -1,6 +1,6 @@ // a cleaner simplification of Blitz Stars' histories because it's a mess there -import { AllStats } from './accountInfo.js'; +import { AllStats } from './accountInfo'; export interface History { all: AllStats; diff --git a/src/types/possiblyPromise.ts b/src/types/possiblyPromise.ts index 005f03fa7..a4658c873 100644 --- a/src/types/possiblyPromise.ts +++ b/src/types/possiblyPromise.ts @@ -1 +1 @@ -export type PossiblyPromise = Promise | Type; \ No newline at end of file +export type PossiblyPromise = Promise | Type; diff --git a/src/types/tanksStats.ts b/src/types/tanksStats.ts index 6cce62112..493f2c75f 100644 --- a/src/types/tanksStats.ts +++ b/src/types/tanksStats.ts @@ -1,4 +1,4 @@ -import { AllStats } from './accountInfo.js'; +import { AllStats } from './accountInfo'; export interface IndividualTankStats { all: AllStats; diff --git a/tsconfig.json b/tsconfig.json index d47b9a960..5f2ace03b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,8 +2,7 @@ "compilerOptions": { "target": "ESNext", "module": "ESNext", - // "moduleResolution": "Node", TODO: implement Node module resolution - "moduleResolution": "nodenext", + "moduleResolution": "Node", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true, @@ -12,5 +11,8 @@ "resolveJsonModule": true, "jsx": "react-jsx" }, - "include": ["src/**/*.ts", "src/components/AllStatsOverview/components/WN8SurroundingStat.tsx"] + "include": [ + "src/**/*.ts", + "src/components/AllStatsOverview/components/WN8SurroundingStat.tsx" + ] } diff --git a/yarn.lock b/yarn.lock index bcaab4082..e74fb6d32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1447,6 +1447,11 @@ preact@^10.0.0: resolved "https://registry.yarnpkg.com/preact/-/preact-10.15.1.tgz#a1de60c9fc0c79a522d969c65dcaddc5d994eede" integrity sha512-qs2ansoQEwzNiV5eAcRT1p1EC/dmEzaATVDJNiB3g2sRDWdA7b7MurXdJjB2+/WQktGWZwxvDrnuRFbWuIr64g== +prettier@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.0.tgz#e7b19f691245a21d618c68bc54dc06122f6105ae" + integrity sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g== + proxy-addr@~2.0.7: version "2.0.7" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" From 0fdc87a88cf8e4b0c59f94b70a2992bbac01bce8 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Wed, 12 Jul 2023 18:35:31 +0000 Subject: [PATCH 25/26] feat: docs --- docs/changelogs/1.10.0.md | 37 +++++++++++++++++++++++++++++++++++++ package.json | 1 - src/commands/fullStats.tsx | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 docs/changelogs/1.10.0.md diff --git a/docs/changelogs/1.10.0.md b/docs/changelogs/1.10.0.md new file mode 100644 index 000000000..d6e164470 --- /dev/null +++ b/docs/changelogs/1.10.0.md @@ -0,0 +1,37 @@ +# Blitzkrieg 1.10.0 + +This update addresses many readability issues that users have reported over time. + +## Changes + +- `/ownedtanks` + - Tanks are now displayed in two columns + - Collector and premium tanks now have their own colors + - Tank types are also displayed + - A stylistic image of the tank is also displayed for each tank to the right +- `/fullstats` + - Was previously called `/statsfull`; this was changed to avoid the clutter that would show up when searching for `/stats` + - Added four catagories in which all the stats are sorted into + - Catagories now have backgrounds to compartmentalize them +- `/evolution` + - Gave the axis markings a high contrast color + - Added a label for the x axis affirming that it is plotted over the number of battles +- `/today` + - Added a border to all the rows to compartmentalize them + - This command can now generate embeds too + - Removed survivability + - Added a limit option to cut off after a certain number of tanks played (this is mainly intended to be used by streamers to limit the content of the embeds) + - Tanks are now displayed in order of the most recent battle +- `/help` + - A significant amount of subcommands were added + - These new subcommands now return normal Discord messages instead of embeds in favor of readability + - The contents of the replies are directly fetched from the Blitzkrieg documentation +- Time zones + - What is considered a "day's worth of battles" has been adjusted as the "reset time" was the same for all Blitz servers + - The reset time is now dependent on the server of the player + - Use `/help timezones` to learn more + +## Technical Changes + +- All themes have been merged to leverage Bepaint's suffixes +- Switched to Node module resolution diff --git a/package.json b/package.json index 296a85345..f0b65c189 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "version": "1.10.0", "description": "", "main": "src/server.ts", - "type": "module", "scripts": { "build:bot": "node scripts/build --build=bot", "build:server": "node scripts/build --build=server", diff --git a/src/commands/fullStats.tsx b/src/commands/fullStats.tsx index de1cdaa85..adbd15159 100644 --- a/src/commands/fullStats.tsx +++ b/src/commands/fullStats.tsx @@ -19,7 +19,7 @@ import { AccountInfo } from '../types/accountInfo'; export const fullStatsCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: addStatTypeSubCommandGroups( From 186d45e3d9a96e15c64384280f99426c3ee0f150 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Wed, 12 Jul 2023 19:06:22 +0000 Subject: [PATCH 26/26] fix: module type --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index f0b65c189..296a85345 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.10.0", "description": "", "main": "src/server.ts", + "type": "module", "scripts": { "build:bot": "node scripts/build --build=bot", "build:server": "node scripts/build --build=server",