mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: some migration
This commit is contained in:
1 parent
e06aaa4bcf
commit
02aed3e3a5
25 files changed
+637
-73
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { Locale } from 'discord.js';
|
||||
import { go } from 'fuzzysort';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { tankNames } from '../blitzkit/nonBlockingPromises';
|
||||
import { tankDefinitions, tankNames } from '../blitzkit/nonBlockingPromises';
|
||||
import { UserError } from '../blitzkit/userError';
|
||||
import { tankNamesTechTreeOnly } from '../discord/autocompleteTanks';
|
||||
import { translator } from '../localization/translator';
|
||||
@@ -34,7 +34,9 @@ export async function resolveTankId(
|
||||
return searchResult[0].obj.id;
|
||||
}
|
||||
} else {
|
||||
if ((await tankDefinitions)[number]) {
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
|
||||
if (awaitedTankDefinitions.tanks[number]) {
|
||||
return number;
|
||||
} else {
|
||||
throw new UserError(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { flagUserActivity, idToRegion, usersDatabase } from '@blitzkit/core';
|
||||
import { idToRegion, usersDatabase } from '@blitzkit/core';
|
||||
import { flagUserActivity } from '@blitzkit/core/src/blitzkit/flagUserActivity';
|
||||
|
||||
export async function getBlitzFromDiscord(discordId: bigint) {
|
||||
const unique = await usersDatabase.discordUser.findUnique({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TankClass, TankType } from '@blitzkit/core';
|
||||
import { TankClass, TankType, Tier } from '@blitzkit/core';
|
||||
import { SupplementaryStats } from '@blitzkit/core/src/blitz/getAccountInfo';
|
||||
import { calculateWN8 } from '@blitzkit/core/src/statistics/calculateWN8';
|
||||
import { BlitzStats } from '@blitzkit/core/src/statistics/compositeStats';
|
||||
@@ -8,7 +8,7 @@ import { blitzStarsTankAverages } from './tankAverages';
|
||||
|
||||
export interface StatFilters {
|
||||
nation?: string;
|
||||
tier?: number;
|
||||
tier?: Tier;
|
||||
class?: TankClass;
|
||||
type?: TankType;
|
||||
tank?: number;
|
||||
|
||||
@@ -62,7 +62,7 @@ export function addFilterOptions<
|
||||
...TANK_CLASSES.map(
|
||||
(tankType) =>
|
||||
({
|
||||
value: tankType,
|
||||
value: `${tankType}`,
|
||||
name: translate(`common.tank_class_short.${tankType}`),
|
||||
name_localizations: localizationObject(
|
||||
`common.tank_class_short.${tankType}`,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { gameDefinitions } from '@blitzkit/core';
|
||||
import {
|
||||
SlashCommandBuilder,
|
||||
SlashCommandSubcommandBuilder,
|
||||
SlashCommandSubcommandGroupBuilder,
|
||||
} from 'discord.js';
|
||||
import { gameDefinitions } from '../blitzkit/nonBlockingPromises';
|
||||
import { addFilterOptions } from './addFilterOptions';
|
||||
import { addPeriodSubCommands } from './addPeriodSubCommands';
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { StatFilters, TreeType } from '@blitzkit/core';
|
||||
import { TankClass, TankType } from '@blitzkit/core';
|
||||
import { ButtonInteraction } from 'discord.js';
|
||||
import { StatFilters } from '../blitzstars/filterStats';
|
||||
|
||||
export function getFiltersFromButton(interaction: ButtonInteraction) {
|
||||
const url = new URL(`https://example.com/${interaction.customId}`);
|
||||
@@ -7,9 +8,12 @@ export function getFiltersFromButton(interaction: ButtonInteraction) {
|
||||
return {
|
||||
nation: url.searchParams.get('nation') ?? undefined,
|
||||
tank: parseInt(url.searchParams.get('tank') ?? '0') || undefined,
|
||||
tankType: url.searchParams.get('tank-class') ?? undefined,
|
||||
treeType:
|
||||
(url.searchParams.get('tree-type') as TreeType | undefined) ?? undefined,
|
||||
class:
|
||||
(Number(url.searchParams.get('class')) as TankClass | undefined) ??
|
||||
undefined,
|
||||
type:
|
||||
(Number(url.searchParams.get('type')) as TankType | undefined) ??
|
||||
undefined,
|
||||
tier: parseInt(url.searchParams.get('tier') ?? '0') || undefined,
|
||||
} satisfies StatFilters;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { StatFilters, TreeType } from '@blitzkit/core';
|
||||
import { TankClass, TankType } from '@blitzkit/core';
|
||||
import { ChatInputCommandInteraction } from 'discord.js';
|
||||
import { resolveTankId } from '../blitz/resolveTankId';
|
||||
import { StatFilters } from '../blitzstars/filterStats';
|
||||
|
||||
export async function getFiltersFromCommand(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
@@ -9,10 +10,13 @@ export async function getFiltersFromCommand(
|
||||
|
||||
return {
|
||||
nation: interaction.options.getString('nation') ?? undefined,
|
||||
tier: parseInt(interaction.options.getString('tier') ?? '0') || undefined,
|
||||
tankType: interaction.options.getString('tank-class') ?? undefined,
|
||||
treeType:
|
||||
(interaction.options.getString('tree-type') as TreeType | undefined) ??
|
||||
tier: Number(interaction.options.getString('tier')),
|
||||
class:
|
||||
(Number(interaction.options.getString('class')) as
|
||||
| TankClass
|
||||
| undefined) ?? undefined,
|
||||
type:
|
||||
(Number(interaction.options.getString('type')) as TankType | undefined) ??
|
||||
undefined,
|
||||
tank:
|
||||
tankRaw === null
|
||||
|
||||
Reference in new issue
Block a user