mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
Merge branch 'main' into ue
This commit is contained in:
commit
bf218b0975
6 files changed
+180
-196
No files matched your search
@@ -0,0 +1,11 @@
|
|||||||
|
# BlitzKit 1.29.14
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- BlitzStars has enabled aggressive Cloudflare protections; hence, disabling BlitzKit from using BlitzStar's API
|
||||||
|
- Disabled the following commands:
|
||||||
|
- `/stats`
|
||||||
|
- `/today`
|
||||||
|
- `/breakdown`
|
||||||
|
- `/evolution`
|
||||||
|
- `/full-stats`
|
||||||
@@ -1,49 +1,46 @@
|
|||||||
import { getBlitzStarsLinkButton } from '../../core/blitzstars/getBlitzStarsLinkButton';
|
import { addPeriodicFilterOptions } from "../../core/discord/addPeriodicFilterOptions";
|
||||||
import { addPeriodicFilterOptions } from '../../core/discord/addPeriodicFilterOptions';
|
import { addUsernameChoices } from "../../core/discord/addUsernameChoices";
|
||||||
import { addUsernameChoices } from '../../core/discord/addUsernameChoices';
|
import { autocompleteTanks } from "../../core/discord/autocompleteTanks";
|
||||||
import { autocompleteTanks } from '../../core/discord/autocompleteTanks';
|
import { autocompleteUsername } from "../../core/discord/autocompleteUsername";
|
||||||
import { autocompleteUsername } from '../../core/discord/autocompleteUsername';
|
import { createLocalizedCommand } from "../../core/discord/createLocalizedCommand";
|
||||||
import { buttonRefresh } from '../../core/discord/buttonRefresh';
|
import { getFiltersFromButton } from "../../core/discord/getFiltersFromButton";
|
||||||
import { commandToURL } from '../../core/discord/commandToURL';
|
import { resolvePeriodFromButton } from "../../core/discord/resolvePeriodFromButton";
|
||||||
import { createLocalizedCommand } from '../../core/discord/createLocalizedCommand';
|
import { resolvePlayerFromButton } from "../../core/discord/resolvePlayerFromButton";
|
||||||
import { getCustomPeriodParams } from '../../core/discord/getCustomPeriodParams';
|
import { translator } from "../../core/localization/translator";
|
||||||
import { getFiltersFromButton } from '../../core/discord/getFiltersFromButton';
|
import type { CommandRegistry } from "../../events/interactionCreate";
|
||||||
import { getFiltersFromCommand } from '../../core/discord/getFiltersFromCommand';
|
import { renderBreakdown } from "./render";
|
||||||
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 type { CommandRegistry } from '../../events/interactionCreate';
|
|
||||||
import { renderBreakdown } from './render';
|
|
||||||
|
|
||||||
export const breakdownCommand = new Promise<CommandRegistry>(
|
export const breakdownCommand = new Promise<CommandRegistry>(
|
||||||
async (resolve) => {
|
async (resolve) => {
|
||||||
resolve({
|
resolve({
|
||||||
command: await addPeriodicFilterOptions(
|
command: await addPeriodicFilterOptions(
|
||||||
createLocalizedCommand('breakdown'),
|
createLocalizedCommand("breakdown"),
|
||||||
(option) => option.addStringOption(addUsernameChoices),
|
(option) => option.addStringOption(addUsernameChoices),
|
||||||
),
|
),
|
||||||
|
|
||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const player = await resolvePlayerFromCommand(interaction);
|
const { strings } = translator(interaction.locale);
|
||||||
const period = resolvePeriodFromCommand(player.region, interaction);
|
return strings.bot.commands.dead;
|
||||||
const filters = await getFiltersFromCommand(interaction);
|
|
||||||
const path = commandToURL(interaction, {
|
|
||||||
...player,
|
|
||||||
...getCustomPeriodParams(interaction),
|
|
||||||
...filters,
|
|
||||||
});
|
|
||||||
|
|
||||||
return [
|
// const player = await resolvePlayerFromCommand(interaction);
|
||||||
...(await renderBreakdown(
|
// const period = resolvePeriodFromCommand(player.region, interaction);
|
||||||
player,
|
// const filters = await getFiltersFromCommand(interaction);
|
||||||
period,
|
// const path = commandToURL(interaction, {
|
||||||
filters,
|
// ...player,
|
||||||
interaction.locale,
|
// ...getCustomPeriodParams(interaction),
|
||||||
)),
|
// ...filters,
|
||||||
buttonRefresh(interaction, path),
|
// });
|
||||||
await getBlitzStarsLinkButton(player.region, player.id),
|
|
||||||
];
|
// return [
|
||||||
|
// ...(await renderBreakdown(
|
||||||
|
// player,
|
||||||
|
// period,
|
||||||
|
// filters,
|
||||||
|
// interaction.locale,
|
||||||
|
// )),
|
||||||
|
// buttonRefresh(interaction, path),
|
||||||
|
// await getBlitzStarsLinkButton(player.region, player.id),
|
||||||
|
// ];
|
||||||
},
|
},
|
||||||
|
|
||||||
autocomplete: (interaction) => {
|
autocomplete: (interaction) => {
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import * as Graph from "../components/Graph";
|
|||||||
import { LineColor } from "../components/Graph/components/Line/constants";
|
import { LineColor } from "../components/Graph/components/Line/constants";
|
||||||
import { NoData } from "../components/NoData";
|
import { NoData } from "../components/NoData";
|
||||||
import { TitleBar } from "../components/TitleBar";
|
import { TitleBar } from "../components/TitleBar";
|
||||||
import { resolveTankId } from "../core/blitz/resolveTankId";
|
|
||||||
import { getBlitzStarsLinkButton } from "../core/blitzstars/getBlitzStarsLinkButton";
|
|
||||||
import { getPlayerHistories } from "../core/blitzstars/getPlayerHistories";
|
import { getPlayerHistories } from "../core/blitzstars/getPlayerHistories";
|
||||||
import { getTankHistories } from "../core/blitzstars/getTankHistories";
|
import { getTankHistories } from "../core/blitzstars/getTankHistories";
|
||||||
import { addPeriodSubCommands } from "../core/discord/addPeriodSubCommands";
|
import { addPeriodSubCommands } from "../core/discord/addPeriodSubCommands";
|
||||||
@@ -14,20 +12,12 @@ import { addTankChoices } from "../core/discord/addTankChoices";
|
|||||||
import { addUsernameChoices } from "../core/discord/addUsernameChoices";
|
import { addUsernameChoices } from "../core/discord/addUsernameChoices";
|
||||||
import { autocompleteTanks } from "../core/discord/autocompleteTanks";
|
import { autocompleteTanks } from "../core/discord/autocompleteTanks";
|
||||||
import { autocompleteUsername } from "../core/discord/autocompleteUsername";
|
import { autocompleteUsername } from "../core/discord/autocompleteUsername";
|
||||||
import { buttonRefresh } from "../core/discord/buttonRefresh";
|
|
||||||
import { commandToURL } from "../core/discord/commandToURL";
|
|
||||||
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
|
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
|
||||||
import { getCustomPeriodParams } from "../core/discord/getCustomPeriodParams";
|
|
||||||
import { resolvePeriodFromButton } from "../core/discord/resolvePeriodFromButton";
|
import { resolvePeriodFromButton } from "../core/discord/resolvePeriodFromButton";
|
||||||
import {
|
import { type ResolvedPeriod } from "../core/discord/resolvePeriodFromCommand";
|
||||||
type ResolvedPeriod,
|
|
||||||
resolvePeriodFromCommand,
|
|
||||||
} from "../core/discord/resolvePeriodFromCommand";
|
|
||||||
import { resolvePlayerFromButton } from "../core/discord/resolvePlayerFromButton";
|
import { resolvePlayerFromButton } from "../core/discord/resolvePlayerFromButton";
|
||||||
import {
|
import { type ResolvedPlayer } from "../core/discord/resolvePlayerFromCommand";
|
||||||
type ResolvedPlayer,
|
import { translator } from "../core/localization/translator";
|
||||||
resolvePlayerFromCommand,
|
|
||||||
} from "../core/discord/resolvePlayerFromCommand";
|
|
||||||
import type { CommandRegistry } from "../events/interactionCreate";
|
import type { CommandRegistry } from "../events/interactionCreate";
|
||||||
|
|
||||||
type EvolutionStatType = "player" | "tank";
|
type EvolutionStatType = "player" | "tank";
|
||||||
@@ -37,7 +27,7 @@ async function render(
|
|||||||
{ start, end, name }: ResolvedPeriod,
|
{ start, end, name }: ResolvedPeriod,
|
||||||
type: "player" | "tank",
|
type: "player" | "tank",
|
||||||
tankId: number | null,
|
tankId: number | null,
|
||||||
locale: Locale
|
locale: Locale,
|
||||||
) {
|
) {
|
||||||
const accountInfo = await getAccountInfo(region, id);
|
const accountInfo = await getAccountInfo(region, id);
|
||||||
const clan = (await getClanAccountInfo(region, id, ["clan"]))?.clan;
|
const clan = (await getClanAccountInfo(region, id, ["clan"]))?.clan;
|
||||||
@@ -61,7 +51,7 @@ async function render(
|
|||||||
[
|
[
|
||||||
history.all.battles,
|
history.all.battles,
|
||||||
(history.all.wins / history.all.battles) * 100,
|
(history.all.wins / history.all.battles) * 100,
|
||||||
] as Graph.PlotItem
|
] as Graph.PlotItem,
|
||||||
);
|
);
|
||||||
const times = histories.map((history) => history.last_battle_time);
|
const times = histories.map((history) => history.last_battle_time);
|
||||||
const minTime = Math.min(...times);
|
const minTime = Math.min(...times);
|
||||||
@@ -115,7 +105,7 @@ export const evolutionCommand = new Promise<CommandRegistry>(
|
|||||||
group: "player",
|
group: "player",
|
||||||
modify(option: SlashCommandSubcommandGroupBuilder) {
|
modify(option: SlashCommandSubcommandGroupBuilder) {
|
||||||
addPeriodSubCommands(option, (option) =>
|
addPeriodSubCommands(option, (option) =>
|
||||||
option.addStringOption(addUsernameChoices)
|
option.addStringOption(addUsernameChoices),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -125,43 +115,46 @@ export const evolutionCommand = new Promise<CommandRegistry>(
|
|||||||
addPeriodSubCommands(option, (option) =>
|
addPeriodSubCommands(option, (option) =>
|
||||||
option
|
option
|
||||||
.addStringOption(addTankChoices)
|
.addStringOption(addTankChoices)
|
||||||
.addStringOption(addUsernameChoices)
|
.addStringOption(addUsernameChoices),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
|
|
||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const commandGroup =
|
const { strings } = translator(interaction.locale);
|
||||||
interaction.options.getSubcommandGroup() as EvolutionStatType;
|
return strings.bot.commands.dead;
|
||||||
const player = await resolvePlayerFromCommand(interaction);
|
|
||||||
const period = resolvePeriodFromCommand(player.region, interaction);
|
|
||||||
const tankIdRaw = interaction.options.getString("tank")!;
|
|
||||||
const tankId =
|
|
||||||
commandGroup === "tank"
|
|
||||||
? await resolveTankId(tankIdRaw, interaction.locale)
|
|
||||||
: null;
|
|
||||||
const path = commandToURL(interaction, {
|
|
||||||
...player,
|
|
||||||
...getCustomPeriodParams(interaction),
|
|
||||||
tankId,
|
|
||||||
});
|
|
||||||
|
|
||||||
return [
|
// const commandGroup =
|
||||||
await render(
|
// interaction.options.getSubcommandGroup() as EvolutionStatType;
|
||||||
player,
|
// const player = await resolvePlayerFromCommand(interaction);
|
||||||
period,
|
// const period = resolvePeriodFromCommand(player.region, interaction);
|
||||||
commandGroup,
|
// const tankIdRaw = interaction.options.getString("tank")!;
|
||||||
tankId,
|
// const tankId =
|
||||||
interaction.locale
|
// commandGroup === "tank"
|
||||||
),
|
// ? await resolveTankId(tankIdRaw, interaction.locale)
|
||||||
buttonRefresh(interaction, path),
|
// : null;
|
||||||
await getBlitzStarsLinkButton(
|
// const path = commandToURL(interaction, {
|
||||||
player.region,
|
// ...player,
|
||||||
player.id,
|
// ...getCustomPeriodParams(interaction),
|
||||||
tankId ?? undefined
|
// tankId,
|
||||||
),
|
// });
|
||||||
];
|
|
||||||
|
// return [
|
||||||
|
// await render(
|
||||||
|
// player,
|
||||||
|
// period,
|
||||||
|
// commandGroup,
|
||||||
|
// tankId,
|
||||||
|
// interaction.locale
|
||||||
|
// ),
|
||||||
|
// buttonRefresh(interaction, path),
|
||||||
|
// await getBlitzStarsLinkButton(
|
||||||
|
// player.region,
|
||||||
|
// player.id,
|
||||||
|
// tankId ?? undefined
|
||||||
|
// ),
|
||||||
|
// ];
|
||||||
},
|
},
|
||||||
|
|
||||||
autocomplete: (interaction) => {
|
autocomplete: (interaction) => {
|
||||||
@@ -181,9 +174,9 @@ export const evolutionCommand = new Promise<CommandRegistry>(
|
|||||||
period,
|
period,
|
||||||
commandGroup,
|
commandGroup,
|
||||||
parseInt(url.searchParams.get("tankId") ?? "0") || null,
|
parseInt(url.searchParams.get("tankId") ?? "0") || null,
|
||||||
interaction.locale
|
interaction.locale,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
@@ -3,38 +3,28 @@ import {
|
|||||||
getAccountInfo,
|
getAccountInfo,
|
||||||
getClanAccountInfo,
|
getClanAccountInfo,
|
||||||
getTierWeights,
|
getTierWeights,
|
||||||
} from '@blitzkit/core';
|
} from "@blitzkit/core";
|
||||||
import { Locale } from 'discord.js';
|
import { Locale } from "discord.js";
|
||||||
import { CommandWrapper } from '../components/CommandWrapper';
|
import { CommandWrapper } from "../components/CommandWrapper";
|
||||||
import { GenericAllStats } from '../components/GenericAllStats';
|
import { GenericAllStats } from "../components/GenericAllStats";
|
||||||
import { NoData } from '../components/NoData';
|
import { NoData } from "../components/NoData";
|
||||||
import { TierWeights } from '../components/TierWeights';
|
import { TierWeights } from "../components/TierWeights";
|
||||||
import { TitleBar } from '../components/TitleBar';
|
import { TitleBar } from "../components/TitleBar";
|
||||||
import { filtersToDescription } from '../core/blitzkit/filtersToDescription';
|
import { filtersToDescription } from "../core/blitzkit/filtersToDescription";
|
||||||
import { filterStats, type StatFilters } from '../core/blitzstars/filterStats';
|
import { filterStats, type StatFilters } from "../core/blitzstars/filterStats";
|
||||||
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
import { getStatsInPeriod } from "../core/blitzstars/getStatsInPeriod";
|
||||||
import { getStatsInPeriod } from '../core/blitzstars/getStatsInPeriod';
|
import { addPeriodicFilterOptions } from "../core/discord/addPeriodicFilterOptions";
|
||||||
import { addPeriodicFilterOptions } from '../core/discord/addPeriodicFilterOptions';
|
import { addUsernameChoices } from "../core/discord/addUsernameChoices";
|
||||||
import { addUsernameChoices } from '../core/discord/addUsernameChoices';
|
import { autocompleteTanks } from "../core/discord/autocompleteTanks";
|
||||||
import { autocompleteTanks } from '../core/discord/autocompleteTanks';
|
import { autocompleteUsername } from "../core/discord/autocompleteUsername";
|
||||||
import { autocompleteUsername } from '../core/discord/autocompleteUsername';
|
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
|
||||||
import { buttonRefresh } from '../core/discord/buttonRefresh';
|
import { getFiltersFromButton } from "../core/discord/getFiltersFromButton";
|
||||||
import { commandToURL } from '../core/discord/commandToURL';
|
import { resolvePeriodFromButton } from "../core/discord/resolvePeriodFromButton";
|
||||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
import { type ResolvedPeriod } from "../core/discord/resolvePeriodFromCommand";
|
||||||
import { getCustomPeriodParams } from '../core/discord/getCustomPeriodParams';
|
import { resolvePlayerFromButton } from "../core/discord/resolvePlayerFromButton";
|
||||||
import { getFiltersFromButton } from '../core/discord/getFiltersFromButton';
|
import { type ResolvedPlayer } from "../core/discord/resolvePlayerFromCommand";
|
||||||
import { getFiltersFromCommand } from '../core/discord/getFiltersFromCommand';
|
import { translator } from "../core/localization/translator";
|
||||||
import { resolvePeriodFromButton } from '../core/discord/resolvePeriodFromButton';
|
import type { CommandRegistry } from "../events/interactionCreate";
|
||||||
import {
|
|
||||||
type ResolvedPeriod,
|
|
||||||
resolvePeriodFromCommand,
|
|
||||||
} from '../core/discord/resolvePeriodFromCommand';
|
|
||||||
import { resolvePlayerFromButton } from '../core/discord/resolvePlayerFromButton';
|
|
||||||
import {
|
|
||||||
type ResolvedPlayer,
|
|
||||||
resolvePlayerFromCommand,
|
|
||||||
} from '../core/discord/resolvePlayerFromCommand';
|
|
||||||
import type { CommandRegistry } from '../events/interactionCreate';
|
|
||||||
|
|
||||||
async function render(
|
async function render(
|
||||||
{ region, id }: ResolvedPlayer,
|
{ region, id }: ResolvedPlayer,
|
||||||
@@ -43,7 +33,7 @@ async function render(
|
|||||||
locale: Locale,
|
locale: Locale,
|
||||||
) {
|
) {
|
||||||
const { nickname } = await getAccountInfo(region, id);
|
const { nickname } = await getAccountInfo(region, id);
|
||||||
const clan = (await getClanAccountInfo(region, id, ['clan']))?.clan;
|
const clan = (await getClanAccountInfo(region, id, ["clan"]))?.clan;
|
||||||
const clanImage = clan ? emblemURL(clan.emblem_set_id) : undefined;
|
const clanImage = clan ? emblemURL(clan.emblem_set_id) : undefined;
|
||||||
const diffedTankStats = await getStatsInPeriod(
|
const diffedTankStats = await getStatsInPeriod(
|
||||||
region,
|
region,
|
||||||
@@ -86,25 +76,28 @@ export const fullStatsCommand = new Promise<CommandRegistry>(
|
|||||||
async (resolve) => {
|
async (resolve) => {
|
||||||
resolve({
|
resolve({
|
||||||
command: await addPeriodicFilterOptions(
|
command: await addPeriodicFilterOptions(
|
||||||
createLocalizedCommand('full-stats'),
|
createLocalizedCommand("full-stats"),
|
||||||
(option) => option.addStringOption(addUsernameChoices),
|
(option) => option.addStringOption(addUsernameChoices),
|
||||||
),
|
),
|
||||||
|
|
||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const player = await resolvePlayerFromCommand(interaction);
|
const { strings } = translator(interaction.locale);
|
||||||
const period = resolvePeriodFromCommand(player.region, interaction);
|
return strings.bot.commands.dead;
|
||||||
const filters = await getFiltersFromCommand(interaction);
|
|
||||||
const path = commandToURL(interaction, {
|
|
||||||
...player,
|
|
||||||
...getCustomPeriodParams(interaction),
|
|
||||||
...filters,
|
|
||||||
});
|
|
||||||
|
|
||||||
return Promise.all([
|
// const player = await resolvePlayerFromCommand(interaction);
|
||||||
render(player, period, filters, interaction.locale),
|
// const period = resolvePeriodFromCommand(player.region, interaction);
|
||||||
buttonRefresh(interaction, path),
|
// const filters = await getFiltersFromCommand(interaction);
|
||||||
getBlitzStarsLinkButton(player.region, player.id),
|
// const path = commandToURL(interaction, {
|
||||||
]);
|
// ...player,
|
||||||
|
// ...getCustomPeriodParams(interaction),
|
||||||
|
// ...filters,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// return Promise.all([
|
||||||
|
// render(player, period, filters, interaction.locale),
|
||||||
|
// buttonRefresh(interaction, path),
|
||||||
|
// getBlitzStarsLinkButton(player.region, player.id),
|
||||||
|
// ]);
|
||||||
},
|
},
|
||||||
|
|
||||||
autocomplete: (interaction) => {
|
autocomplete: (interaction) => {
|
||||||
|
|||||||
@@ -6,35 +6,25 @@ 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 { filterStats, type StatFilters } from "../core/blitzstars/filterStats";
|
import { filterStats, type StatFilters } from "../core/blitzstars/filterStats";
|
||||||
import { getBlitzStarsLinkButton } from "../core/blitzstars/getBlitzStarsLinkButton";
|
|
||||||
import { getStatsInPeriod } from "../core/blitzstars/getStatsInPeriod";
|
import { getStatsInPeriod } from "../core/blitzstars/getStatsInPeriod";
|
||||||
import { addPeriodicFilterOptions } from "../core/discord/addPeriodicFilterOptions";
|
import { addPeriodicFilterOptions } from "../core/discord/addPeriodicFilterOptions";
|
||||||
import { addUsernameChoices } from "../core/discord/addUsernameChoices";
|
import { addUsernameChoices } from "../core/discord/addUsernameChoices";
|
||||||
import { autocompleteTanks } from "../core/discord/autocompleteTanks";
|
import { autocompleteTanks } from "../core/discord/autocompleteTanks";
|
||||||
import { autocompleteUsername } from "../core/discord/autocompleteUsername";
|
import { autocompleteUsername } from "../core/discord/autocompleteUsername";
|
||||||
import { buttonRefresh } from "../core/discord/buttonRefresh";
|
|
||||||
import { commandToURL } from "../core/discord/commandToURL";
|
|
||||||
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
|
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
|
||||||
import { getCustomPeriodParams } from "../core/discord/getCustomPeriodParams";
|
|
||||||
import { getFiltersFromButton } from "../core/discord/getFiltersFromButton";
|
import { getFiltersFromButton } from "../core/discord/getFiltersFromButton";
|
||||||
import { getFiltersFromCommand } from "../core/discord/getFiltersFromCommand";
|
|
||||||
import { resolvePeriodFromButton } from "../core/discord/resolvePeriodFromButton";
|
import { resolvePeriodFromButton } from "../core/discord/resolvePeriodFromButton";
|
||||||
import {
|
import { type ResolvedPeriod } from "../core/discord/resolvePeriodFromCommand";
|
||||||
type ResolvedPeriod,
|
|
||||||
resolvePeriodFromCommand,
|
|
||||||
} from "../core/discord/resolvePeriodFromCommand";
|
|
||||||
import { resolvePlayerFromButton } from "../core/discord/resolvePlayerFromButton";
|
import { resolvePlayerFromButton } from "../core/discord/resolvePlayerFromButton";
|
||||||
import {
|
import { type ResolvedPlayer } from "../core/discord/resolvePlayerFromCommand";
|
||||||
type ResolvedPlayer,
|
import { translator } from "../core/localization/translator";
|
||||||
resolvePlayerFromCommand,
|
|
||||||
} from "../core/discord/resolvePlayerFromCommand";
|
|
||||||
import type { CommandRegistry } from "../events/interactionCreate";
|
import type { CommandRegistry } from "../events/interactionCreate";
|
||||||
|
|
||||||
async function render(
|
async function render(
|
||||||
{ region, id }: ResolvedPlayer,
|
{ region, id }: ResolvedPlayer,
|
||||||
{ start, end, name }: ResolvedPeriod,
|
{ start, end, name }: ResolvedPeriod,
|
||||||
filters: StatFilters,
|
filters: StatFilters,
|
||||||
locale: Locale
|
locale: Locale,
|
||||||
) {
|
) {
|
||||||
const { nickname } = await getAccountInfo(region, id);
|
const { nickname } = await getAccountInfo(region, id);
|
||||||
const clan = (await getClanAccountInfo(region, id, ["clan"]))?.clan;
|
const clan = (await getClanAccountInfo(region, id, ["clan"]))?.clan;
|
||||||
@@ -44,7 +34,7 @@ async function render(
|
|||||||
id,
|
id,
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
locale
|
locale,
|
||||||
);
|
);
|
||||||
const { stats, supplementary } = await filterStats(diffedTankStats, filters);
|
const { stats, supplementary } = await filterStats(diffedTankStats, filters);
|
||||||
const filterDescriptions = await filtersToDescription(filters, locale);
|
const filterDescriptions = await filtersToDescription(filters, locale);
|
||||||
@@ -73,24 +63,27 @@ export const statsCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
resolve({
|
resolve({
|
||||||
command: await addPeriodicFilterOptions(
|
command: await addPeriodicFilterOptions(
|
||||||
createLocalizedCommand("stats"),
|
createLocalizedCommand("stats"),
|
||||||
(option) => option.addStringOption(addUsernameChoices)
|
(option) => option.addStringOption(addUsernameChoices),
|
||||||
),
|
),
|
||||||
|
|
||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const player = await resolvePlayerFromCommand(interaction);
|
const { strings } = translator(interaction.locale);
|
||||||
const period = resolvePeriodFromCommand(player.region, interaction);
|
return strings.bot.commands.dead;
|
||||||
const filters = await getFiltersFromCommand(interaction);
|
|
||||||
const path = commandToURL(interaction, {
|
|
||||||
...player,
|
|
||||||
...getCustomPeriodParams(interaction),
|
|
||||||
...filters,
|
|
||||||
});
|
|
||||||
|
|
||||||
return Promise.all([
|
// const player = await resolvePlayerFromCommand(interaction);
|
||||||
render(player, period, filters, interaction.locale),
|
// const period = resolvePeriodFromCommand(player.region, interaction);
|
||||||
buttonRefresh(interaction, path),
|
// const filters = await getFiltersFromCommand(interaction);
|
||||||
getBlitzStarsLinkButton(player.region, player.id),
|
// const path = commandToURL(interaction, {
|
||||||
]);
|
// ...player,
|
||||||
|
// ...getCustomPeriodParams(interaction),
|
||||||
|
// ...filters,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// return Promise.all([
|
||||||
|
// render(player, period, filters, interaction.locale),
|
||||||
|
// buttonRefresh(interaction, path),
|
||||||
|
// getBlitzStarsLinkButton(player.region, player.id),
|
||||||
|
// ]);
|
||||||
},
|
},
|
||||||
|
|
||||||
autocomplete: (interaction) => {
|
autocomplete: (interaction) => {
|
||||||
|
|||||||
@@ -1,50 +1,47 @@
|
|||||||
import { gameDefinitions } from '../core/blitzkit/nonBlockingPromises';
|
import { gameDefinitions } from "../core/blitzkit/nonBlockingPromises";
|
||||||
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
import { addFilterOptions } from "../core/discord/addFilterOptions";
|
||||||
import { addFilterOptions } from '../core/discord/addFilterOptions';
|
import { addUsernameChoices } from "../core/discord/addUsernameChoices";
|
||||||
import { addUsernameChoices } from '../core/discord/addUsernameChoices';
|
import { autocompleteTanks } from "../core/discord/autocompleteTanks";
|
||||||
import { autocompleteTanks } from '../core/discord/autocompleteTanks';
|
import { autocompleteUsername } from "../core/discord/autocompleteUsername";
|
||||||
import { autocompleteUsername } from '../core/discord/autocompleteUsername';
|
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
|
||||||
import { buttonRefresh } from '../core/discord/buttonRefresh';
|
import { getFiltersFromButton } from "../core/discord/getFiltersFromButton";
|
||||||
import { commandToURL } from '../core/discord/commandToURL';
|
import { resolvePeriodFromButton } from "../core/discord/resolvePeriodFromButton";
|
||||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
import { resolvePlayerFromButton } from "../core/discord/resolvePlayerFromButton";
|
||||||
import { getCustomPeriodParams } from '../core/discord/getCustomPeriodParams';
|
import { translator } from "../core/localization/translator";
|
||||||
import { getFiltersFromButton } from '../core/discord/getFiltersFromButton';
|
import { type CommandRegistry } from "../events/interactionCreate";
|
||||||
import { getFiltersFromCommand } from '../core/discord/getFiltersFromCommand';
|
import { renderBreakdown } from "./breakdown/render";
|
||||||
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 { type CommandRegistry } from '../events/interactionCreate';
|
|
||||||
import { renderBreakdown } from './breakdown/render';
|
|
||||||
|
|
||||||
export const todayCommand = new Promise<CommandRegistry>(async (resolve) => {
|
export const todayCommand = new Promise<CommandRegistry>(async (resolve) => {
|
||||||
const awaitedGameDefinitions = await gameDefinitions;
|
const awaitedGameDefinitions = await gameDefinitions;
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
command: addFilterOptions(
|
command: addFilterOptions(
|
||||||
createLocalizedCommand('today'),
|
createLocalizedCommand("today"),
|
||||||
awaitedGameDefinitions.nations,
|
awaitedGameDefinitions.nations,
|
||||||
).addStringOption(addUsernameChoices),
|
).addStringOption(addUsernameChoices),
|
||||||
|
|
||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const player = await resolvePlayerFromCommand(interaction);
|
const { strings } = translator(interaction.locale);
|
||||||
const period = resolvePeriodFromCommand(
|
return strings.bot.commands.dead;
|
||||||
player.region,
|
|
||||||
interaction,
|
|
||||||
'today',
|
|
||||||
);
|
|
||||||
const filters = await getFiltersFromCommand(interaction);
|
|
||||||
const path = commandToURL(interaction, {
|
|
||||||
...player,
|
|
||||||
...getCustomPeriodParams(interaction, true),
|
|
||||||
...filters,
|
|
||||||
});
|
|
||||||
|
|
||||||
return [
|
// const player = await resolvePlayerFromCommand(interaction);
|
||||||
...(await renderBreakdown(player, period, filters, interaction.locale)),
|
// const period = resolvePeriodFromCommand(
|
||||||
buttonRefresh(interaction, path),
|
// player.region,
|
||||||
await getBlitzStarsLinkButton(player.region, player.id),
|
// interaction,
|
||||||
];
|
// 'today',
|
||||||
|
// );
|
||||||
|
// const filters = await getFiltersFromCommand(interaction);
|
||||||
|
// const path = commandToURL(interaction, {
|
||||||
|
// ...player,
|
||||||
|
// ...getCustomPeriodParams(interaction, true),
|
||||||
|
// ...filters,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// return [
|
||||||
|
// ...(await renderBreakdown(player, period, filters, interaction.locale)),
|
||||||
|
// buttonRefresh(interaction, path),
|
||||||
|
// await getBlitzStarsLinkButton(player.region, player.id),
|
||||||
|
// ];
|
||||||
},
|
},
|
||||||
|
|
||||||
autocomplete: (interaction) => {
|
autocomplete: (interaction) => {
|
||||||
|
|||||||
Reference in new issue
Block a user