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