feat: seasonal stats

This commit is contained in:
TrèsAbhi committed 2024-06-06 19:31:53 -05:00
1 parent 5031b4f8e3
commit 378f56598d
2 files changed
+35 -5

No files matched your search

+20 -4
View File
@@ -1,3 +1,4 @@
import { SlashCommandSubcommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape'; import markdownEscape from 'markdown-escape';
import { Glow } from '../components/AllStatsOverview/components/HeroStat/components/Glow'; import { Glow } from '../components/AllStatsOverview/components/HeroStat/components/Glow';
import CommandWrapper from '../components/CommandWrapper'; import CommandWrapper from '../components/CommandWrapper';
@@ -31,13 +32,28 @@ const LEAGUE_ACCENT = [
export const ratingCommand = new Promise<CommandRegistry>((resolve) => { export const ratingCommand = new Promise<CommandRegistry>((resolve) => {
resolve({ resolve({
command: command: createLocalizedCommand('rating', [
createLocalizedCommand('rating').addStringOption(addUsernameChoices), {
subcommand: 'today',
modify(option: SlashCommandSubcommandBuilder) {
option.addStringOption(addUsernameChoices);
},
},
{
subcommand: 'season',
modify(option: SlashCommandSubcommandBuilder) {
option.addStringOption(addUsernameChoices);
},
},
]),
inProduction: true, inProduction: true,
inPublic: true, inPublic: true,
async handler(interaction) { async handler(interaction) {
const subcommand = interaction.options.getSubcommand(true) as
| 'season'
| 'today';
const { t, translate } = translator(interaction.locale); const { t, translate } = translator(interaction.locale);
const { id, region } = await resolvePlayerFromCommand(interaction); const { id, region } = await resolvePlayerFromCommand(interaction);
const clan = (await getClanAccountInfo(region, id, ['clan']))?.clan; const clan = (await getClanAccountInfo(region, id, ['clan']))?.clan;
@@ -51,7 +67,7 @@ export const ratingCommand = new Promise<CommandRegistry>((resolve) => {
const leaderboard = await getArchivedRatingMidnightLeaderboard( const leaderboard = await getArchivedRatingMidnightLeaderboard(
region, region,
ratingInfo.current_season, ratingInfo.current_season - (subcommand === 'today' ? 0 : 1),
); );
if (leaderboard?.format === BkrlFormat.Base) { if (leaderboard?.format === BkrlFormat.Base) {
@@ -101,7 +117,7 @@ export const ratingCommand = new Promise<CommandRegistry>((resolve) => {
<TitleBar <TitleBar
title={accountInfo.nickname} title={accountInfo.nickname}
image={clanImage} image={clanImage}
description={`${t`bot.commands.rating.body.subtitle`} • ${new Date().toLocaleDateString( description={`${translate(`bot.commands.rating.body.subtitle.${subcommand}`)} • ${new Date().toLocaleDateString(
interaction.locale, interaction.locale,
)}`} )}`}
/> />
+15 -1
View File
@@ -562,8 +562,22 @@
"$": "rating-session", "$": "rating-session",
"description": "Rating player's statistics", "description": "Rating player's statistics",
"subcommands": {
"today": {
"$": "today",
"description": "Today's rating statistics"
},
"season": {
"$": "season",
"description": "This season's rating statistics"
}
},
"body": { "body": {
"subtitle": "Today's rating statistics" "subtitle": {
"today": "Today's rating statistics",
"season": "This season's rating statistics"
}
}, },
"errors": { "errors": {