fix: /statsfull now uses null tankId when not available

This commit is contained in:
TresAbhi committed 2023-06-28 18:48:10 +00:00
1 parent d1d8aad6c7
commit c2d2d076f0
2 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ export default {
const player = await resolvePlayerFromCommand(interaction);
const period = resolvePeriodFromCommand(interaction);
const tankIdRaw = interaction.options.getString('tank')!;
const tankId = commandGroup === 'tank' ? resolveTankId(tankIdRaw) : 0;
const tankId = commandGroup === 'tank' ? resolveTankId(tankIdRaw) : null;
const start = interaction.options.getInteger('start');
const end = interaction.options.getInteger('end');
const path = interactionToURL(interaction, {
+6 -6
View File
@@ -28,7 +28,7 @@ export default async function statsfull<Type extends StatType>(
type: Type,
{ start, end, statsName }: ResolvedPeriod,
{ server, id }: ResolvedPlayer,
tankId: Type extends 'tank' ? number : never,
tankId: Type extends 'tank' ? number : null,
) {
let nameDiscriminator: string | undefined;
let image: string | undefined;
@@ -45,8 +45,8 @@ export default async function statsfull<Type extends StatType>(
? `https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${clan.emblem_set_id}.png`
: undefined;
} else if (type === 'tank') {
nameDiscriminator = `(${resolveTankName(tankId)})`;
image = tankopedia[tankId].images.normal;
nameDiscriminator = `(${resolveTankName(tankId!)})`;
image = tankopedia[tankId!].images.normal;
}
const tankStats = await getTankStatsDiffed(server, id, start, end);
@@ -112,11 +112,11 @@ export default async function statsfull<Type extends StatType>(
{},
);
} else {
stats = tankStats[tankId];
stats = tankStats[tankId!];
supplementaryStats = {
WN8: calculateWN8(tankAverages[tankId].all, tankStats[tankId]),
tier: tankopedia[tankId].tier,
WN8: calculateWN8(tankAverages[tankId!].all, tankStats[tankId!]),
tier: tankopedia[tankId!].tier,
};
}