mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: more linting
This commit is contained in:
1 parent
766801826c
commit
6261dfc9cd
10 files changed
+377
-383
No files matched your search
@@ -6,23 +6,23 @@ import {
|
|||||||
getTankStats,
|
getTankStats,
|
||||||
getWN8Percentile,
|
getWN8Percentile,
|
||||||
TankDefinition,
|
TankDefinition,
|
||||||
} from '@blitzkit/core';
|
} from "@blitzkit/core";
|
||||||
import { literals } from '@blitzkit/i18n';
|
import { literals } from "@blitzkit/i18n";
|
||||||
import { Locale } from 'discord.js';
|
import { Locale } from "discord.js";
|
||||||
import { chunk } from 'lodash-es';
|
import { chunk } from "lodash-es";
|
||||||
import * as Breakdown from '../../components/Breakdown';
|
import * as Breakdown from "../../components/Breakdown";
|
||||||
import { CommandWrapper } from '../../components/CommandWrapper';
|
import { CommandWrapper } from "../../components/CommandWrapper";
|
||||||
import { NoData } from '../../components/NoData';
|
import { NoData } from "../../components/NoData";
|
||||||
import { TitleBar } from '../../components/TitleBar';
|
import { TitleBar } from "../../components/TitleBar";
|
||||||
import { filtersToDescription } from '../../core/blitzkit/filtersToDescription';
|
import { filtersToDescription } from "../../core/blitzkit/filtersToDescription";
|
||||||
import { tankDefinitions } from '../../core/blitzkit/nonBlockingPromises';
|
import { tankDefinitions } from "../../core/blitzkit/nonBlockingPromises";
|
||||||
import { UserError } from '../../core/blitzkit/userError';
|
import { UserError } from "../../core/blitzkit/userError";
|
||||||
import { filterStats, StatFilters } from '../../core/blitzstars/filterStats';
|
import { filterStats, StatFilters } from "../../core/blitzstars/filterStats";
|
||||||
import { getStatsInPeriod } from '../../core/blitzstars/getStatsInPeriod';
|
import { getStatsInPeriod } from "../../core/blitzstars/getStatsInPeriod";
|
||||||
import { blitzStarsTankAverages } from '../../core/blitzstars/tankAverages';
|
import { blitzStarsTankAverages } from "../../core/blitzstars/tankAverages";
|
||||||
import { ResolvedPeriod } from '../../core/discord/resolvePeriodFromCommand';
|
import { ResolvedPeriod } from "../../core/discord/resolvePeriodFromCommand";
|
||||||
import { ResolvedPlayer } from '../../core/discord/resolvePlayerFromCommand';
|
import { ResolvedPlayer } from "../../core/discord/resolvePlayerFromCommand";
|
||||||
import { translator } from '../../core/localization/translator';
|
import { translator } from "../../core/localization/translator";
|
||||||
|
|
||||||
const ROWS_PER_PAGE = 8;
|
const ROWS_PER_PAGE = 8;
|
||||||
const MAX_PAGES = 9;
|
const MAX_PAGES = 9;
|
||||||
@@ -31,7 +31,7 @@ export async function renderBreakdown(
|
|||||||
{ region, id }: ResolvedPlayer,
|
{ region, id }: ResolvedPlayer,
|
||||||
{ start, end, name }: ResolvedPeriod,
|
{ start, end, name }: ResolvedPeriod,
|
||||||
filters: StatFilters,
|
filters: StatFilters,
|
||||||
locale: Locale,
|
locale: Locale
|
||||||
) {
|
) {
|
||||||
const { strings, unwrap } = translator(locale);
|
const { strings, unwrap } = translator(locale);
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const awaitedTankDefinitions = await tankDefinitions;
|
||||||
@@ -39,7 +39,7 @@ export async function renderBreakdown(
|
|||||||
const statsInPeriod = await getStatsInPeriod(region, id, start, end, locale);
|
const statsInPeriod = await getStatsInPeriod(region, id, start, end, locale);
|
||||||
const { filteredOrder } = await filterStats(statsInPeriod, filters);
|
const { filteredOrder } = await filterStats(statsInPeriod, filters);
|
||||||
const accountInfo = await getAccountInfo(region, id);
|
const accountInfo = await getAccountInfo(region, id);
|
||||||
const clanData = await getClanAccountInfo(region, id, ['clan']);
|
const clanData = await getClanAccountInfo(region, id, ["clan"]);
|
||||||
const tankStats = await getTankStats(region, id);
|
const tankStats = await getTankStats(region, id);
|
||||||
const filterDescriptions = await filtersToDescription(filters, locale);
|
const filterDescriptions = await filtersToDescription(filters, locale);
|
||||||
const orderedCurrentStats: BlitzStats[] = [];
|
const orderedCurrentStats: BlitzStats[] = [];
|
||||||
@@ -74,63 +74,63 @@ export async function renderBreakdown(
|
|||||||
orderedCareerWN8Full.push(
|
orderedCareerWN8Full.push(
|
||||||
tankAveragesEntry
|
tankAveragesEntry
|
||||||
? calculateWN8(tankAveragesEntry.all, tank.all)
|
? calculateWN8(tankAveragesEntry.all, tank.all)
|
||||||
: undefined,
|
: undefined
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentBattles = orderedCurrentStats.reduce(
|
const currentBattles = orderedCurrentStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.battles,
|
(accumulator, current) => accumulator + current.battles,
|
||||||
0,
|
0
|
||||||
);
|
);
|
||||||
const careerBattles = tankStats.reduce(
|
const careerBattles = tankStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.all.battles,
|
(accumulator, current) => accumulator + current.all.battles,
|
||||||
0,
|
0
|
||||||
);
|
);
|
||||||
const currentWinrate =
|
const currentWinrate =
|
||||||
orderedCurrentStats.reduce(
|
orderedCurrentStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.wins,
|
(accumulator, current) => accumulator + current.wins,
|
||||||
0,
|
0
|
||||||
) / currentBattles;
|
) / currentBattles;
|
||||||
const careerWinrate =
|
const careerWinrate =
|
||||||
tankStats.reduce(
|
tankStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.all.wins,
|
(accumulator, current) => accumulator + current.all.wins,
|
||||||
0,
|
0
|
||||||
) / careerBattles;
|
) / careerBattles;
|
||||||
const currentWN8 =
|
const currentWN8 =
|
||||||
orderedCurrentWN8.reduce<number>(
|
orderedCurrentWN8.reduce<number>(
|
||||||
(accumulator, current, index) =>
|
(accumulator, current, index) =>
|
||||||
accumulator + (current ?? 0) * orderedCurrentStats[index].battles,
|
accumulator + (current ?? 0) * orderedCurrentStats[index].battles,
|
||||||
0,
|
0
|
||||||
) /
|
) /
|
||||||
orderedCurrentStats.reduce(
|
orderedCurrentStats.reduce(
|
||||||
(accumulator, current, index) =>
|
(accumulator, current, index) =>
|
||||||
accumulator +
|
accumulator +
|
||||||
(orderedCurrentWN8[index] === undefined ? 0 : current.battles),
|
(orderedCurrentWN8[index] === undefined ? 0 : current.battles),
|
||||||
0,
|
0
|
||||||
);
|
);
|
||||||
const careerWN8 =
|
const careerWN8 =
|
||||||
orderedCareerWN8Full.reduce<number>(
|
orderedCareerWN8Full.reduce<number>(
|
||||||
(accumulator, current) => accumulator + (current ?? 0),
|
(accumulator, current) => accumulator + (current ?? 0),
|
||||||
0,
|
0
|
||||||
) /
|
) /
|
||||||
tankStats.reduce(
|
tankStats.reduce(
|
||||||
(accumulator, current, index) =>
|
(accumulator, current, index) =>
|
||||||
accumulator +
|
accumulator +
|
||||||
(orderedCareerWN8Full[index] === undefined ? 0 : current.all.battles),
|
(orderedCareerWN8Full[index] === undefined ? 0 : current.all.battles),
|
||||||
0,
|
0
|
||||||
);
|
);
|
||||||
const currentDamage =
|
const currentDamage =
|
||||||
orderedCurrentStats.reduce(
|
orderedCurrentStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.damage_dealt,
|
(accumulator, current) => accumulator + current.damage_dealt,
|
||||||
0,
|
0
|
||||||
) / currentBattles;
|
) / currentBattles;
|
||||||
const careerDamage =
|
const careerDamage =
|
||||||
tankStats.reduce(
|
tankStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.all.damage_dealt,
|
(accumulator, current) => accumulator + current.all.damage_dealt,
|
||||||
0,
|
0
|
||||||
) / careerBattles;
|
) / careerBattles;
|
||||||
|
|
||||||
const children: JSX.Element[] = [];
|
const children: React.JSX.Element[] = [];
|
||||||
|
|
||||||
if (filteredOrder.length > 0) {
|
if (filteredOrder.length > 0) {
|
||||||
children.push(
|
children.push(
|
||||||
@@ -172,7 +172,7 @@ export async function renderBreakdown(
|
|||||||
delta: currentDamage - careerDamage,
|
delta: currentDamage - careerDamage,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>,
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
filteredOrder.forEach((id, index) => {
|
filteredOrder.forEach((id, index) => {
|
||||||
@@ -206,7 +206,7 @@ export async function renderBreakdown(
|
|||||||
{
|
{
|
||||||
title: strings.bot.commands.breakdown.body.winrate,
|
title: strings.bot.commands.breakdown.body.winrate,
|
||||||
current: `${(100 * (current.wins / current.battles)).toFixed(
|
current: `${(100 * (current.wins / current.battles)).toFixed(
|
||||||
2,
|
2
|
||||||
)}%`,
|
)}%`,
|
||||||
career: `${(100 * (career.wins / career.battles)).toFixed(2)}%`,
|
career: `${(100 * (career.wins / career.battles)).toFixed(2)}%`,
|
||||||
delta:
|
delta:
|
||||||
@@ -230,24 +230,24 @@ export async function renderBreakdown(
|
|||||||
{
|
{
|
||||||
title: strings.bot.commands.breakdown.body.damage,
|
title: strings.bot.commands.breakdown.body.damage,
|
||||||
current: Math.round(
|
current: Math.round(
|
||||||
current.damage_dealt / current.battles,
|
current.damage_dealt / current.battles
|
||||||
).toLocaleString(),
|
).toLocaleString(),
|
||||||
career: Math.round(
|
career: Math.round(
|
||||||
career.damage_dealt / career.battles,
|
career.damage_dealt / career.battles
|
||||||
).toLocaleString(),
|
).toLocaleString(),
|
||||||
delta:
|
delta:
|
||||||
current.damage_dealt / current.battles -
|
current.damage_dealt / current.battles -
|
||||||
career.damage_dealt / career.battles,
|
career.damage_dealt / career.battles,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>,
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const pages = chunk(
|
const pages = chunk(
|
||||||
children,
|
children,
|
||||||
Math.max(Math.ceil(children.length / MAX_PAGES), ROWS_PER_PAGE),
|
Math.max(Math.ceil(children.length / MAX_PAGES), ROWS_PER_PAGE)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (filteredOrder.length > 0) {
|
if (filteredOrder.length > 0) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { jsxToSvg } from './jsxToSvg';
|
import { jsxToSvg } from "./jsxToSvg";
|
||||||
import { svgToPng } from './svgToPng';
|
import { svgToPng } from "./svgToPng";
|
||||||
|
|
||||||
export async function jsxToPng(jsx: JSX.Element) {
|
export async function jsxToPng(jsx: React.JSX.Element) {
|
||||||
const svg = await jsxToSvg(jsx);
|
const svg = await jsxToSvg(jsx);
|
||||||
const png = svgToPng(svg);
|
const png = svgToPng(svg);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { jsxToSvg } from './jsxToSvg';
|
import { jsxToSvg } from "./jsxToSvg";
|
||||||
import { RenderConfiguration } from './renderConfiguration';
|
import { RenderConfiguration } from "./renderConfiguration";
|
||||||
import { svgToPngThreaded } from './svgToPngThreaded';
|
import { svgToPngThreaded } from "./svgToPngThreaded";
|
||||||
|
|
||||||
export async function jsxToPngThreaded(
|
export async function jsxToPngThreaded(
|
||||||
jsx: JSX.Element,
|
jsx: React.JSX.Element,
|
||||||
renderConfiguration: RenderConfiguration,
|
renderConfiguration: RenderConfiguration
|
||||||
) {
|
) {
|
||||||
const svg = await jsxToSvg(jsx, renderConfiguration);
|
const svg = await jsxToSvg(jsx, renderConfiguration);
|
||||||
const png = await svgToPngThreaded(svg);
|
const png = await svgToPngThreaded(svg);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { readFile } from 'fs/promises';
|
import { readFile } from "fs/promises";
|
||||||
import satori from 'satori';
|
import satori from "satori";
|
||||||
import { RenderConfiguration } from '../renderConfiguration';
|
import { RenderConfiguration } from "../renderConfiguration";
|
||||||
import robotoBlack from './Roboto-Black.ttf';
|
import robotoBlack from "./Roboto-Black.ttf";
|
||||||
import robotoBold from './Roboto-Bold.ttf';
|
import robotoBold from "./Roboto-Bold.ttf";
|
||||||
import roboto from './Roboto.ttf';
|
import roboto from "./Roboto.ttf";
|
||||||
|
|
||||||
const fontsPromise = [
|
const fontsPromise = [
|
||||||
{ file: roboto, weight: 400 as const },
|
{ file: roboto, weight: 400 as const },
|
||||||
@@ -11,12 +11,12 @@ const fontsPromise = [
|
|||||||
{ file: robotoBlack, weight: 900 as const },
|
{ file: robotoBlack, weight: 900 as const },
|
||||||
].map(async ({ file, weight }) => {
|
].map(async ({ file, weight }) => {
|
||||||
const data = await readFile(`${__dirname}/${file}`);
|
const data = await readFile(`${__dirname}/${file}`);
|
||||||
return { name: 'Roboto', weight, data };
|
return { name: "Roboto", weight, data };
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function jsxToSvg(
|
export async function jsxToSvg(
|
||||||
jsx: JSX.Element,
|
jsx: React.JSX.Element,
|
||||||
renderConfiguration = new RenderConfiguration(),
|
renderConfiguration = new RenderConfiguration()
|
||||||
) {
|
) {
|
||||||
const fonts = await Promise.all(fontsPromise);
|
const fonts = await Promise.all(fontsPromise);
|
||||||
return await satori(jsx, { width: renderConfiguration.width, fonts });
|
return await satori(jsx, { width: renderConfiguration.width, fonts });
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ import {
|
|||||||
InteractionEditReplyOptions,
|
InteractionEditReplyOptions,
|
||||||
InteractionReplyOptions,
|
InteractionReplyOptions,
|
||||||
MessageEditOptions,
|
MessageEditOptions,
|
||||||
} from 'discord.js';
|
} from "discord.js";
|
||||||
import { InteractionReturnable } from '../../events/interactionCreate';
|
import { InteractionReturnable } from "../../events/interactionCreate";
|
||||||
import { Writeable } from '../../types/writable';
|
import { Writeable } from "../../types/writable";
|
||||||
import { jsxToPngThreaded } from '../blitzkit/jsxToPngThreaded';
|
import { jsxToPngThreaded } from "../blitzkit/jsxToPngThreaded";
|
||||||
import { RenderConfiguration } from '../blitzkit/renderConfiguration';
|
import { RenderConfiguration } from "../blitzkit/renderConfiguration";
|
||||||
|
|
||||||
export async function normalizeInteractionReturnable(
|
export async function normalizeInteractionReturnable(
|
||||||
returnable: InteractionReturnable,
|
returnable: InteractionReturnable
|
||||||
) {
|
) {
|
||||||
const images: [number, Buffer][] = [];
|
const images: [number, Buffer][] = [];
|
||||||
const reply: InteractionEditReplyOptions &
|
const reply: InteractionEditReplyOptions &
|
||||||
@@ -27,7 +27,7 @@ export async function normalizeInteractionReturnable(
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
normalizedReturnable.map(async (item, index) => {
|
normalizedReturnable.map(async (item, index) => {
|
||||||
if (typeof item === 'string') {
|
if (typeof item === "string") {
|
||||||
reply.content = item;
|
reply.content = item;
|
||||||
} else if (item instanceof EmbedBuilder) {
|
} else if (item instanceof EmbedBuilder) {
|
||||||
if (!reply.embeds) reply.embeds = [];
|
if (!reply.embeds) reply.embeds = [];
|
||||||
@@ -36,7 +36,7 @@ export async function normalizeInteractionReturnable(
|
|||||||
if (!reply.components)
|
if (!reply.components)
|
||||||
reply.components = [new ActionRowBuilder<ButtonBuilder>()];
|
reply.components = [new ActionRowBuilder<ButtonBuilder>()];
|
||||||
(reply.components[0] as ActionRowBuilder<ButtonBuilder>).addComponents(
|
(reply.components[0] as ActionRowBuilder<ButtonBuilder>).addComponents(
|
||||||
item,
|
item
|
||||||
);
|
);
|
||||||
} else if (item instanceof AttachmentBuilder) {
|
} else if (item instanceof AttachmentBuilder) {
|
||||||
if (!reply.files) reply.files = [];
|
if (!reply.files) reply.files = [];
|
||||||
@@ -49,14 +49,14 @@ export async function normalizeInteractionReturnable(
|
|||||||
const image = await jsxToPngThreaded(item, renderConfiguration);
|
const image = await jsxToPngThreaded(item, renderConfiguration);
|
||||||
images.push([index, image]);
|
images.push([index, image]);
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
if (images.length > 0) {
|
if (images.length > 0) {
|
||||||
images.sort(([a], [b]) => b - a);
|
images.sort(([a], [b]) => b - a);
|
||||||
if (!reply.files) reply.files = [];
|
if (!reply.files) reply.files = [];
|
||||||
images.forEach(([, image]) =>
|
images.forEach(([, image]) =>
|
||||||
(reply.files as Writeable<typeof reply.files>)?.push(image),
|
(reply.files as Writeable<typeof reply.files>)?.push(image)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { DEFAULT_LOCALE, SupportedLocale } from '@blitzkit/i18n';
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
import { Locale } from 'discord.js';
|
import { Locale } from "discord.js";
|
||||||
|
|
||||||
const SUPPORTED_LOCALES_DISCORD_MAP: Record<SupportedLocale, Locale> = {
|
const SUPPORTED_LOCALES_DISCORD_MAP: Record<string, Locale> = {
|
||||||
en: Locale.EnglishUS,
|
en: Locale.EnglishUS,
|
||||||
es: Locale.SpanishES,
|
es: Locale.SpanishES,
|
||||||
pt: Locale.PortugueseBR,
|
pt: Locale.PortugueseBR,
|
||||||
@@ -14,12 +14,12 @@ const SUPPORTED_LOCALES_DISCORD_MAP: Record<SupportedLocale, Locale> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const SUPPORTED_LOCALES_DISCORD_MAP_INVERSE = Object.fromEntries(
|
export const SUPPORTED_LOCALES_DISCORD_MAP_INVERSE = Object.fromEntries(
|
||||||
Object.entries(SUPPORTED_LOCALES_DISCORD_MAP).map(([k, v]) => [v, k]),
|
Object.entries(SUPPORTED_LOCALES_DISCORD_MAP).map(([k, v]) => [v, k])
|
||||||
) as Record<Locale, SupportedLocale>;
|
) as Record<Locale, string>;
|
||||||
|
|
||||||
export const SUPPORTED_LOCALES_DISCORD = Object.values(
|
export const SUPPORTED_LOCALES_DISCORD = Object.values(
|
||||||
SUPPORTED_LOCALES_DISCORD_MAP,
|
SUPPORTED_LOCALES_DISCORD_MAP
|
||||||
);
|
);
|
||||||
|
|
||||||
export const DEFAULT_LOCALE_DISCORD =
|
export const DEFAULT_LOCALE_DISCORD =
|
||||||
SUPPORTED_LOCALES_DISCORD_MAP[DEFAULT_LOCALE];
|
SUPPORTED_LOCALES_DISCORD_MAP[locales.default];
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { assertSecret } from '@blitzkit/core';
|
import { assertSecret } from "@blitzkit/core";
|
||||||
import {
|
import {
|
||||||
AttachmentBuilder,
|
AttachmentBuilder,
|
||||||
AutocompleteInteraction,
|
AutocompleteInteraction,
|
||||||
@@ -13,30 +13,30 @@ import {
|
|||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
SlashCommandOptionsOnlyBuilder,
|
SlashCommandOptionsOnlyBuilder,
|
||||||
SlashCommandSubcommandsOnlyBuilder,
|
SlashCommandSubcommandsOnlyBuilder,
|
||||||
} from 'discord.js';
|
} from "discord.js";
|
||||||
import { aboutCommand } from '../../commands/about';
|
import { aboutCommand } from "../../commands/about";
|
||||||
import { breakdownCommand } from '../../commands/breakdown';
|
import { breakdownCommand } from "../../commands/breakdown";
|
||||||
import { debugCommand } from '../../commands/debug';
|
import { debugCommand } from "../../commands/debug";
|
||||||
import { evolutionCommand } from '../../commands/evolution';
|
import { evolutionCommand } from "../../commands/evolution";
|
||||||
import { fullStatsCommand } from '../../commands/fullStats';
|
import { fullStatsCommand } from "../../commands/fullStats";
|
||||||
import { inactiveCommand } from '../../commands/inactive';
|
import { inactiveCommand } from "../../commands/inactive";
|
||||||
import { verifyCommand } from '../../commands/link';
|
import { verifyCommand } from "../../commands/link";
|
||||||
import { ownedTanksCommand } from '../../commands/ownedTanks';
|
import { ownedTanksCommand } from "../../commands/ownedTanks";
|
||||||
import { permissionsCommand } from '../../commands/permissions';
|
import { permissionsCommand } from "../../commands/permissions";
|
||||||
import { pingCommand } from '../../commands/ping';
|
import { pingCommand } from "../../commands/ping";
|
||||||
import { playerInfoCommand } from '../../commands/playerInfo';
|
import { playerInfoCommand } from "../../commands/playerInfo";
|
||||||
import { ratingCommand } from '../../commands/rating';
|
import { ratingCommand } from "../../commands/rating";
|
||||||
import { ratingLeaderboardCommand } from '../../commands/ratingLeaderboard';
|
import { ratingLeaderboardCommand } from "../../commands/ratingLeaderboard";
|
||||||
import { replayCommand } from '../../commands/replay';
|
import { replayCommand } from "../../commands/replay";
|
||||||
import { researchCommand } from '../../commands/research';
|
import { researchCommand } from "../../commands/research";
|
||||||
import { searchClansCommand } from '../../commands/searchClans';
|
import { searchClansCommand } from "../../commands/searchClans";
|
||||||
import { searchPlayersCommand } from '../../commands/searchPlayers';
|
import { searchPlayersCommand } from "../../commands/searchPlayers";
|
||||||
import { statsCommand } from '../../commands/stats';
|
import { statsCommand } from "../../commands/stats";
|
||||||
import { todayCommand } from '../../commands/today';
|
import { todayCommand } from "../../commands/today";
|
||||||
import { RenderConfiguration } from '../../core/blitzkit/renderConfiguration';
|
import { RenderConfiguration } from "../../core/blitzkit/renderConfiguration";
|
||||||
import { handleAutocomplete } from './handlers/autocomplete';
|
import { handleAutocomplete } from "./handlers/autocomplete";
|
||||||
import { handleButton } from './handlers/button';
|
import { handleButton } from "./handlers/button";
|
||||||
import { handleChatInputCommand } from './handlers/chatInputCommand';
|
import { handleChatInputCommand } from "./handlers/chatInputCommand";
|
||||||
|
|
||||||
export type InteractionRawReturnable =
|
export type InteractionRawReturnable =
|
||||||
| string
|
| string
|
||||||
@@ -44,7 +44,7 @@ export type InteractionRawReturnable =
|
|||||||
| ButtonBuilder
|
| ButtonBuilder
|
||||||
| AttachmentBuilder
|
| AttachmentBuilder
|
||||||
| RenderConfiguration
|
| RenderConfiguration
|
||||||
| JSX.Element
|
| React.JSX.Element
|
||||||
| null;
|
| null;
|
||||||
export type InteractionIterableReturnable =
|
export type InteractionIterableReturnable =
|
||||||
| InteractionRawReturnable
|
| InteractionRawReturnable
|
||||||
@@ -58,7 +58,7 @@ interface CommandRegistryBase {
|
|||||||
| SlashCommandBuilder
|
| SlashCommandBuilder
|
||||||
| SlashCommandSubcommandsOnlyBuilder
|
| SlashCommandSubcommandsOnlyBuilder
|
||||||
| SlashCommandOptionsOnlyBuilder
|
| SlashCommandOptionsOnlyBuilder
|
||||||
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
| Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">;
|
||||||
|
|
||||||
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
||||||
button?: (interaction: ButtonInteraction<CacheType>) => InteractionReturnable;
|
button?: (interaction: ButtonInteraction<CacheType>) => InteractionReturnable;
|
||||||
@@ -72,7 +72,7 @@ interface CommandRegistryImplicit extends CommandRegistryBase {
|
|||||||
interface CommandRegistryExplicit extends CommandRegistryBase {
|
interface CommandRegistryExplicit extends CommandRegistryBase {
|
||||||
handlesInteraction?: false;
|
handlesInteraction?: false;
|
||||||
handler: (
|
handler: (
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>
|
||||||
) => InteractionReturnable;
|
) => InteractionReturnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,16 +104,16 @@ export const COMMANDS_RAW: Promise<CommandRegistry>[] = [
|
|||||||
export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => {
|
export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => {
|
||||||
return rawCommands.reduce<Record<string, CommandRegistry>>(
|
return rawCommands.reduce<Record<string, CommandRegistry>>(
|
||||||
(commands, registry, index) => {
|
(commands, registry, index) => {
|
||||||
if (registry.status === 'rejected') {
|
if (registry.status === "rejected") {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Command ${index} failed to load; skipping...`,
|
`Command ${index} failed to load; skipping...`,
|
||||||
registry.reason,
|
registry.reason
|
||||||
);
|
);
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
return { ...commands, [registry.value.command.name]: registry.value };
|
return { ...commands, [registry.value.command.name]: registry.value };
|
||||||
},
|
},
|
||||||
{},
|
{}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -121,12 +121,12 @@ const rest = new REST().setToken(assertSecret(import.meta.env.DISCORD_TOKEN));
|
|||||||
|
|
||||||
commands.then((awaitedCommands) => {
|
commands.then((awaitedCommands) => {
|
||||||
const body = Object.values(awaitedCommands).map((registry) =>
|
const body = Object.values(awaitedCommands).map((registry) =>
|
||||||
registry.command.toJSON(),
|
registry.command.toJSON()
|
||||||
);
|
);
|
||||||
|
|
||||||
rest.put(
|
rest.put(
|
||||||
Routes.applicationCommands(assertSecret(import.meta.env.DISCORD_CLIENT_ID)),
|
Routes.applicationCommands(assertSecret(import.meta.env.DISCORD_CLIENT_ID)),
|
||||||
{ body },
|
{ body }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -1,29 +1,26 @@
|
|||||||
import {
|
import { type TranslationTree } from "@blitzkit/i18n";
|
||||||
DEFAULT_LOCALE,
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
SUPPORTED_LOCALES,
|
import { writeFile } from "fs/promises";
|
||||||
TranslationTree,
|
|
||||||
} from '@blitzkit/i18n';
|
|
||||||
import { writeFile } from 'fs/promises';
|
|
||||||
|
|
||||||
const ROOT = '@blitzkit/i18n/strings';
|
const ROOT = "@blitzkit/i18n/strings";
|
||||||
const WORKING_ROOT = '../../packages/i18n/strings';
|
const WORKING_ROOT = "../../packages/i18n/strings";
|
||||||
|
|
||||||
const defaultStrings = require(`${ROOT}/${DEFAULT_LOCALE}.json`).default;
|
const defaultStrings = require(`${ROOT}/${locales.default}.json`).default;
|
||||||
const nonDefaultLocales = SUPPORTED_LOCALES.filter(
|
const nonDefaultLocales = locales.supported.filter(
|
||||||
(locale) => locale !== DEFAULT_LOCALE,
|
({ locale }) => locale !== locales.default
|
||||||
);
|
);
|
||||||
|
|
||||||
function prune(defaultStrings: TranslationTree, strings: TranslationTree) {
|
function prune(defaultStrings: TranslationTree, strings: TranslationTree) {
|
||||||
for (const key in strings) {
|
for (const key in strings) {
|
||||||
if (key in defaultStrings) {
|
if (key in defaultStrings) {
|
||||||
if (typeof defaultStrings[key] === typeof strings[key]) {
|
if (typeof defaultStrings[key] === typeof strings[key]) {
|
||||||
if (typeof strings[key] === 'string') {
|
if (typeof strings[key] === "string") {
|
||||||
if (
|
if (
|
||||||
// are equivalent regardless of %s flavor
|
// are equivalent regardless of %s flavor
|
||||||
(defaultStrings[key] as string).replaceAll(/%s\d/g, '%s') ===
|
(defaultStrings[key] as string).replaceAll(/%s\d/g, "%s") ===
|
||||||
(strings[key] as string).replaceAll(/%s\d/g, '%s') ||
|
(strings[key] as string).replaceAll(/%s\d/g, "%s") ||
|
||||||
// string is empty
|
// string is empty
|
||||||
strings[key] === '' ||
|
strings[key] === "" ||
|
||||||
// string has old flavor of %s
|
// string has old flavor of %s
|
||||||
strings[key].match(/%s([^\d]|$)/g) !== null
|
strings[key].match(/%s([^\d]|$)/g) !== null
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CaretRightIcon } from '@radix-ui/react-icons';
|
import { CaretRightIcon } from "@radix-ui/react-icons";
|
||||||
import { Box, Flex, Link, Text } from '@radix-ui/themes';
|
import { Box, Flex, Link, Text } from "@radix-ui/themes";
|
||||||
import { Var } from '../../../core/radix/var';
|
import { Var } from "../../../core/radix/var";
|
||||||
import type { TankGuide } from '../../../pages/[...locale]/tanks/[slug]/index.astro';
|
import type { TankGuide } from "../../../pages/[...locale]/tanks/[slug]/index.astro";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
guide: TankGuide;
|
guide: TankGuide;
|
||||||
@@ -16,10 +16,10 @@ export function GuideSection({ guide }: Props) {
|
|||||||
underline="none"
|
underline="none"
|
||||||
highContrast
|
highContrast
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
maxWidth: '35rem',
|
maxWidth: "35rem",
|
||||||
flexDirection: 'column',
|
flexDirection: "column",
|
||||||
gap: Var('space-4'),
|
gap: Var("space-4"),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Flex maxWidth="35rem" direction="column" gap="4">
|
<Flex maxWidth="35rem" direction="column" gap="4">
|
||||||
@@ -28,9 +28,9 @@ export function GuideSection({ guide }: Props) {
|
|||||||
<Flex width="100%" justify="start" align="center" gap="2">
|
<Flex width="100%" justify="start" align="center" gap="2">
|
||||||
<img
|
<img
|
||||||
style={{
|
style={{
|
||||||
width: '1.5em',
|
width: "1.5em",
|
||||||
height: '1.5em',
|
height: "1.5em",
|
||||||
objectFit: 'contain',
|
objectFit: "contain",
|
||||||
}}
|
}}
|
||||||
src="https://guidesblitz.com/wp-content/uploads/2023/11/cropped-logo-1.png"
|
src="https://guidesblitz.com/wp-content/uploads/2023/11/cropped-logo-1.png"
|
||||||
/>
|
/>
|
||||||
@@ -39,7 +39,7 @@ export function GuideSection({ guide }: Props) {
|
|||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Text size="2">{guide.description}</Text>
|
<Text size="2">{guide.description}</Text>
|
||||||
<img style={{ width: '100%' }} src={guide.image} />
|
<img style={{ width: "100%" }} src={guide.image} />
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
position="absolute"
|
position="absolute"
|
||||||
@@ -48,7 +48,7 @@ export function GuideSection({ guide }: Props) {
|
|||||||
height="100%"
|
height="100%"
|
||||||
left="0"
|
left="0"
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(${Var('gray-a1')}, ${Var('gray-1')})`,
|
background: `linear-gradient(${Var("gray-a1")}, ${Var("gray-1")})`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
Reference in new issue
Block a user