mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: seasonal stats
This commit is contained in:
1 parent
5031b4f8e3
commit
378f56598d
2 files changed
+35
-5
No files matched your search
+20
-4
@@ -1,3 +1,4 @@
|
||||
import { SlashCommandSubcommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { Glow } from '../components/AllStatsOverview/components/HeroStat/components/Glow';
|
||||
import CommandWrapper from '../components/CommandWrapper';
|
||||
@@ -31,13 +32,28 @@ const LEAGUE_ACCENT = [
|
||||
|
||||
export const ratingCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
command:
|
||||
createLocalizedCommand('rating').addStringOption(addUsernameChoices),
|
||||
command: createLocalizedCommand('rating', [
|
||||
{
|
||||
subcommand: 'today',
|
||||
modify(option: SlashCommandSubcommandBuilder) {
|
||||
option.addStringOption(addUsernameChoices);
|
||||
},
|
||||
},
|
||||
{
|
||||
subcommand: 'season',
|
||||
modify(option: SlashCommandSubcommandBuilder) {
|
||||
option.addStringOption(addUsernameChoices);
|
||||
},
|
||||
},
|
||||
]),
|
||||
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
async handler(interaction) {
|
||||
const subcommand = interaction.options.getSubcommand(true) as
|
||||
| 'season'
|
||||
| 'today';
|
||||
const { t, translate } = translator(interaction.locale);
|
||||
const { id, region } = await resolvePlayerFromCommand(interaction);
|
||||
const clan = (await getClanAccountInfo(region, id, ['clan']))?.clan;
|
||||
@@ -51,7 +67,7 @@ export const ratingCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
|
||||
const leaderboard = await getArchivedRatingMidnightLeaderboard(
|
||||
region,
|
||||
ratingInfo.current_season,
|
||||
ratingInfo.current_season - (subcommand === 'today' ? 0 : 1),
|
||||
);
|
||||
|
||||
if (leaderboard?.format === BkrlFormat.Base) {
|
||||
@@ -101,7 +117,7 @@ export const ratingCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
<TitleBar
|
||||
title={accountInfo.nickname}
|
||||
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,
|
||||
)}`}
|
||||
/>
|
||||
|
||||
+15
-1
@@ -562,8 +562,22 @@
|
||||
"$": "rating-session",
|
||||
"description": "Rating player's statistics",
|
||||
|
||||
"subcommands": {
|
||||
"today": {
|
||||
"$": "today",
|
||||
"description": "Today's rating statistics"
|
||||
},
|
||||
"season": {
|
||||
"$": "season",
|
||||
"description": "This season's rating statistics"
|
||||
}
|
||||
},
|
||||
|
||||
"body": {
|
||||
"subtitle": "Today's rating statistics"
|
||||
"subtitle": {
|
||||
"today": "Today's rating statistics",
|
||||
"season": "This season's rating statistics"
|
||||
}
|
||||
},
|
||||
|
||||
"errors": {
|
||||
|
||||
Reference in new issue
Block a user