mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
fix: all commands now work with a lack of tankopedia entries
This commit is contained in:
1 parent
f907c79d68
commit
ca208e44a1
12 files changed
+59
-26
No files matched your search
@@ -39,7 +39,7 @@ export default async function evolution<Type extends StatType>(
|
||||
: undefined;
|
||||
} else {
|
||||
nameDiscriminator = `(${await resolveTankName(tankId!)})`;
|
||||
image = (await tankopedia)[tankId!].images.normal;
|
||||
image = (await tankopedia)[tankId!]?.images.normal;
|
||||
}
|
||||
|
||||
let histories: Histories;
|
||||
|
||||
@@ -49,7 +49,7 @@ export default async function stats<Type extends StatType>(
|
||||
: undefined;
|
||||
} else if (type === 'tank') {
|
||||
nameDiscriminator = `(${await resolveTankName(tankId!)})`;
|
||||
image = (await tankopedia)[tankId!].images.normal;
|
||||
image = (await tankopedia)[tankId!]?.images.normal;
|
||||
}
|
||||
|
||||
const tankStats = await getTankStatsDiffed(server, id, start, end);
|
||||
@@ -109,7 +109,11 @@ export default async function stats<Type extends StatType>(
|
||||
tierWeights = await entries.reduce<PossiblyPromise<TierWeightsRecord>>(
|
||||
async (accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
const tier = (await tankopedia)[tankId].tier as Tier;
|
||||
const tankopediaEntry = (await tankopedia)[tankId];
|
||||
|
||||
if (!tankopediaEntry) return accumulator;
|
||||
|
||||
const tier = tankopediaEntry.tier as Tier;
|
||||
|
||||
if ((await accumulator)[tier]) {
|
||||
(await accumulator)[tier]! += stats.battles;
|
||||
@@ -128,7 +132,7 @@ export default async function stats<Type extends StatType>(
|
||||
WN8: stats
|
||||
? calculateWN8((await tankAverages)[tankId!].all, tankStats[tankId!])
|
||||
: undefined,
|
||||
tier: (await tankopedia)[tankId!].tier,
|
||||
tier: (await tankopedia)[tankId!]?.tier,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export default async function statsfull<Type extends StatType>(
|
||||
: undefined;
|
||||
} else if (type === 'tank') {
|
||||
nameDiscriminator = `(${await resolveTankName(tankId!)})`;
|
||||
image = (await tankopedia)[tankId!].images.normal;
|
||||
image = (await tankopedia)[tankId!]?.images.normal;
|
||||
}
|
||||
|
||||
const tankStats = await getTankStatsDiffed(server, id, start, end);
|
||||
@@ -111,7 +111,7 @@ export default async function statsfull<Type extends StatType>(
|
||||
|
||||
if (!tankopediaEntry) return accumulator;
|
||||
|
||||
const tier = (await tankopedia)[tankId].tier as Tier;
|
||||
const tier = tankopediaEntry.tier as Tier;
|
||||
|
||||
if ((await accumulator)[tier]) {
|
||||
(await accumulator)[tier]! += stats.battles;
|
||||
@@ -128,7 +128,7 @@ export default async function statsfull<Type extends StatType>(
|
||||
|
||||
supplementaryStats = {
|
||||
WN8: calculateWN8((await tankAverages)[tankId!].all, tankStats[tankId!]),
|
||||
tier: (await tankopedia)[tankId!].tier,
|
||||
tier: (await tankopedia)[tankId!]?.tier,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ export default async function today({ server, id }: ResolvedPlayer) {
|
||||
icon={
|
||||
tankId === 0
|
||||
? undefined
|
||||
: (await tankopedia)[tankIdString as unknown as number].images
|
||||
: (await tankopedia)[tankIdString as unknown as number]?.images
|
||||
.normal
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user