Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/discord-bot/src/commands/arcade/modes/dropper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { arrayGroup, formatRaceTime, formatTime } from "@statsify/util";
import type { LocalizeFunction } from "@statsify/discord";
import type { ProfileTime } from "#commands/base.hypixel-command";

const formatTimeWithSeconds = (time: number) => formatTime(time, { entries: 3 });

interface DropperTableProps {
stats: Dropper;
submode: SubModeForMode<ArcadeModes, "dropper">;
Expand All @@ -34,7 +36,7 @@ export const DropperTable = ({ stats, submode, t, time }: DropperTableProps) =>
<If condition={stats.bestTime > 0}>
<Table.tr>
<Historical.exclude time={time}>
<Table.td title={t("stats.bestTime")} value={formatTime(stats.bestTime)} color="§d" />
<Table.td title={t("stats.bestTime")} value={formatTimeWithSeconds(stats.bestTime)} color="§d" />
</Historical.exclude>
<Table.td title={t("stats.flawlessGames")} value={t(stats.flawlessGames)} color="§5" />
</Table.tr>
Expand Down
3 changes: 3 additions & 0 deletions apps/discord-bot/src/commands/arcade/modes/galaxy-wars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ export const GalaxyWarsTable = ({ stats, t }: GalaxyWarsTableProps) => (
<Table.td title={t("stats.deaths")} value={t(stats.deaths)} color="§c" />
<Table.td title={t("stats.kdr")} value={t(stats.kdr)} color="§6" />
</Table.tr>
<Table.tr>
<Table.td title={t("stats.shotsFired")} value={t(stats.shotsFired)} color="§b" />
</Table.tr>
</Table.table>
);
7 changes: 5 additions & 2 deletions apps/discord-bot/src/commands/arcade/modes/zombies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ interface ZombiesMapColumnProps {

const ZombiesMapColumn = ({ title, stats, t, time }: ZombiesMapColumnProps) => {
const mapStat = stats.wins >= 1 ?
[t("stats.fastestWin"), stats.fastestWin ? formatTime(stats.fastestWin) : "N/A"] :
[t("stats.fastestWin"), stats.fastestWin ? formatTime(stats.fastestWin, { entries: 3 }) : "N/A"] :
[t("stats.bestRound"), t(stats.bestRound)];

return (
<Table.ts title={title}>
<Table.td title={t("stats.wins")} value={t(stats.wins)} color="§a" size="small" />
<Table.td title={t("stats.kills")} value={t(stats.kills)} color="§e" size="small" />
<Historical.exclude time={time}>
<Table.td title={mapStat[0]} value={mapStat[1]} color="§e" size="small" />
</Historical.exclude>
Expand All @@ -50,6 +51,8 @@ export const ZombiesTable = ({ stats, t, time }: ZombiesTableProps) => {
<Table.td title={t("stats.wins")} value={t(overall.wins)} color="§a" />
<Table.td title={t("stats.kills")} value={t(overall.kills)} color="§e" />
<Table.td title={t("stats.deaths")} value={t(overall.deaths)} color="§c" />
<Table.td title={t("stats.kdr")} value={t(overall.kdr)} color="§6" />
<Table.td title={t("stats.totalRounds")} value={t(overall.totalRounds)} color="§d" />
</Table.tr>
</Table.ts>
<Table.tr>
Expand Down Expand Up @@ -89,7 +92,7 @@ export const ZombiesMapDifficultyTable = ({ stats, t, time }: ZombiesMapDifficul
</Table.tr>
<Historical.exclude time={time}>
<Table.tr>
<Table.td title={t("stats.fastestWin")} value={stats.fastestWin ? formatTime(stats.fastestWin) : "N/A"} color="§b" size="small" />
<Table.td title={t("stats.fastestWin")} value={stats.fastestWin ? formatTime(stats.fastestWin, { entries: 3 }) : "N/A"} color="§b" size="small" />
<Table.td title={t("stats.totalRounds")} value={t(stats.totalRounds)} color="§d" size="small" />
</Table.tr>
</Historical.exclude>
Expand Down
8 changes: 6 additions & 2 deletions apps/discord-bot/src/commands/bedwars/bedwars.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export const BedWarsProfile = ({
time,
}: BedWarsProfileProps) => {
const { bedwars } = player.stats;
const stats = bedwars[mode.api];
const modeKey = mode.submode?.api ?? mode.api;
const formattedMode = mode.submode?.api === mode.api || !mode.submode ?
mode.formatted :
`${mode.formatted} ${mode.submode.formatted}`;
const stats = bedwars[modeKey];

const sidebar: SidebarItem[] = [
[t("stats.tokens"), t(bedwars.tokens), "§2"],
Expand Down Expand Up @@ -64,7 +68,7 @@ export const BedWarsProfile = ({
name={player.prefixName}
badge={badge}
sidebar={sidebar}
title={`§l${FormattedGame.BEDWARS} §fStats §r(${mode.formatted})`}
title={`§l${FormattedGame.BEDWARS} §fStats §r(${formattedMode})`}
description={`§7${t("stats.level")}: ${
bedwars.levelFormatted
}\n${formatProgression({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { CopsAndCrimsModes, FormattedGame, type GameMode } from "@statsify/schem
import { formatTime } from "@statsify/util";
import type { BaseProfileProps } from "#commands/base.hypixel-command";

const formatTimeWithSeconds = (time: number) => formatTime(time, { entries: 3 });

export interface CopsAndCrimsProfileProps extends BaseProfileProps {
mode: GameMode<CopsAndCrimsModes>;
}
Expand Down Expand Up @@ -106,7 +108,7 @@ export const CopsAndCrimsProfile = ({
<Historical.exclude time={time}>
<Table.td
title={t("stats.bestTime")}
value={formatTime(stats.fastestWin)}
value={formatTimeWithSeconds(stats.fastestWin)}
color="§b"
/>
</Historical.exclude>
Expand Down
5 changes: 4 additions & 1 deletion apps/discord-bot/src/commands/duels/duels.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { formatTime, prettify } from "@statsify/util";
import type { BaseProfileProps, ProfileTime } from "#commands/base.hypixel-command";
import type { DuelsModeIcons } from "./duels.command.js";

const formatTimeWithSeconds = (time: number) => formatTime(time, { entries: 3 });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't recreate this function in every file. Declare it once.


export type DuelsProfileProps<T extends ProfileTime> = Omit<BaseProfileProps, "time"> & {
mode: GameMode<DuelsModes>;
time: T;
Expand All @@ -42,6 +44,7 @@ export const DuelsProfile = <T extends ProfileTime>({
const sidebar: SidebarItem[] = [
[t("stats.tokens"), t(duels.tokens), "§2"],
[t("stats.pingRange"), `${t(duels.pingRange)}ms`, "§a"],
[t("stats.gamesPlayed"), t(duels.overall.wins + duels.overall.losses), "§e"],
[t("stats.blocksPlaced"), t(duels.overall.blocksPlaced), "§9"],
];

Expand All @@ -61,7 +64,7 @@ export const DuelsProfile = <T extends ProfileTime>({

if (mode.api === "parkour") {
sidebar.push(
[t("stats.bestTime"), duels.parkour.bestTime === 0 ? "N/A" : formatTime(duels.parkour.bestTime), "§d"],
[t("stats.bestTime"), duels.parkour.bestTime === 0 ? "N/A" : formatTimeWithSeconds(duels.parkour.bestTime), "§d"],
[t("stats.checkpoints"), t(duels.parkour.checkpoints), "§5"]
);
}
Expand Down
10 changes: 10 additions & 0 deletions apps/discord-bot/src/commands/general/general.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ export const GeneralProfile = ({
value={t(challenges.total)}
color="§a"
/>
<Table.td
title={t("stats.totalWins")}
value={t(general.totalWins)}
color="§e"
/>
<Table.td
title={t("stats.totalKills")}
value={t(general.totalKills)}
color="§e"
/>
</Table.tr>
<Table.tr>
<Table.td title={t("stats.karma")} value={t(general.karma)} color="§d" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
import { formatTime } from "@statsify/util";
import type { BaseProfileProps } from "#commands/base.hypixel-command";

const formatTimeWithSeconds = (time: number) => formatTime(time, { entries: 3 });

export interface MurderMysteryProfileProps extends BaseProfileProps {
mode: GameMode<MurderMysteryModes>;
}
Expand Down Expand Up @@ -199,7 +201,7 @@ export const MurderMysteryProfile = ({
title={t("stats.fastestMurdererWin")}
value={
stats.fastestMurdererWin ?
formatTime(stats.fastestMurdererWin) :
formatTimeWithSeconds(stats.fastestMurdererWin) :
"N/A"
}
color="§c"
Expand All @@ -208,7 +210,7 @@ export const MurderMysteryProfile = ({
title={t("stats.fastestDetectiveWin")}
value={
stats.fastestDetectiveWin ?
formatTime(stats.fastestDetectiveWin) :
formatTimeWithSeconds(stats.fastestDetectiveWin) :
"N/A"
}
color="§b"
Expand Down
4 changes: 3 additions & 1 deletion apps/discord-bot/src/commands/parkour/parkour.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { formatTime } from "@statsify/util";
import type { BaseProfileProps } from "#commands/base.hypixel-command";
import type { Image } from "skia-canvas";

const formatTimeWithSeconds = (time: number) => formatTime(time, { entries: 3 });

interface ParkourProfileProps extends BaseProfileProps {
gameIcons: Record<GameId, Image>;
}
Expand All @@ -29,7 +31,7 @@ export const ParkourProfile = ({

const times: [GameId, any][] = Object.entries(parkour)
.sort((a, b) => (a[1] || Number.MAX_VALUE) - (b[1] || Number.MAX_VALUE))
.map(([field, time]) => [field as GameId, time ? formatTime(time) : "N/A"]);
.map(([field, time]) => [field as GameId, time ? formatTimeWithSeconds(time) : "N/A"]);

return (
<Container background={background}>
Expand Down
8 changes: 8 additions & 0 deletions apps/discord-bot/src/commands/pit/pit.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const PitProfile = ({

const sidebar: SidebarItem[] = [
[t("stats.gold"), t(pit.gold), "§6"],
[t("stats.totalExp"), t(pit.exp), "§b"],
[t("stats.contracts"), t(pit.contractsCompleted), "§a"],
[t("stats.renown"), t(pit.renown), "§e"],
[t("stats.lifetimeRenown"), t(pit.lifetimeRenown), "§b"],
Expand All @@ -54,6 +55,13 @@ export const PitProfile = ({
currentLevel: pit.levelFormatted,
nextLevel: pit.nextLevelFormatted,
showLevel: true,
})}\n${formatProgression({
t,
label: t("stats.progression.gold"),
progression: pit.goldProgression,
currentLevel: pit.levelFormatted,
nextLevel: pit.nextLevelFormatted,
showLevel: false,
})}`}
sidebar={sidebar}
badge={badge}
Expand Down
10 changes: 9 additions & 1 deletion apps/discord-bot/src/commands/quake/quake.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const QuakeProfile = ({
[t("stats.godlikes"), t(quake.godlikes), "§3"],
[t("stats.trigger"), `${quake.trigger}s`, "§b"],
[t("stats.highestKillstreak"), t(quake.highestKillstreak), "§4"],
[t("stats.blocksTravelled"), t(quake[mode.api].blocksTravelled), "§b"],
];

return (
Expand Down Expand Up @@ -78,10 +79,17 @@ export const QuakeProfile = ({
value={t(stats.shotsFired)}
color="§a"
/>
<Table.td title={t("stats.headshots")} value={t(stats.headshots)} color="§c" />
<Table.td title={t("stats.headshots")} value={t(stats.headshots)} color="§6" />
</Table.tr>
<Table.tr>
<Table.td
title={t("stats.shotAccuracy")}
value={`${stats.quakeShotAccuracy}%`}
color="§a"
/>
<Table.td
title={t("stats.headshotAccuracy")}
value={`${stats.headshotAccuracy}%`}
color="§6"
/>
</Table.tr>
Expand Down
4 changes: 3 additions & 1 deletion apps/discord-bot/src/commands/rankings/rankings.command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export class RankingsCommand {
return scrollingPagination(
context,
groups.map(
(group) => () =>
(group, page) => () =>
render(
<RankingsProfile
background={background}
Expand All @@ -359,6 +359,8 @@ export class RankingsCommand {
t={t}
user={user}
game={formattedGame}
page={page}
pageCount={groups.length}
/>,
getTheme(user)
)
Expand Down
5 changes: 5 additions & 0 deletions apps/discord-bot/src/commands/rankings/rankings.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const formatStat = (stat: PostLeaderboardRankingsResponse, game?: string) => {
export interface RankingsProfileProps extends Omit<BaseProfileProps, "time"> {
data: PostLeaderboardRankingsResponse[];
game?: string;
page: number;
pageCount: number;
}

export const RankingsProfile = ({
Expand All @@ -56,6 +58,8 @@ export const RankingsProfile = ({
skin,
game,
badge,
page,
pageCount,
}: RankingsProfileProps) => {
const listTitles = ["Statistic", "Pos", "Value"];
if (!game) listTitles.unshift("Game");
Expand Down Expand Up @@ -102,6 +106,7 @@ export const RankingsProfile = ({
skin={skin}
time="LIVE"
title={`§l§bLeaderboard Positions §r(§l${formattedGame}§r)`}
description={`§7Page ${t(page + 1)} / ${t(pageCount)}`}
badge={badge}
/>
<List items={[<>{titles}</>, ...items]} />
Expand Down
9 changes: 6 additions & 3 deletions apps/discord-bot/src/commands/tntgames/tntgames.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { FormattedGame, type GameMode, type TNTGamesModes } from "@statsify/sche
import { formatTime, prettify } from "@statsify/util";
import type { BaseProfileProps } from "#commands/base.hypixel-command";

const formatTimeWithSeconds = (time: number) => formatTime(time, { entries: 3 });

export interface TNTGamesProfileProps extends BaseProfileProps {
mode: GameMode<TNTGamesModes>;
}
Expand All @@ -31,6 +33,7 @@ export const TNTGamesProfile = ({
const sidebar: SidebarItem[] = [
[t("stats.coins"), t(tntgames.coins), "§6"],
[t("stats.overallWins"), t(tntgames.wins), "§e"],
[t("stats.playtime"), formatTime(tntgames.playtime), "§a"],
];

let table;
Expand All @@ -47,7 +50,7 @@ export const TNTGamesProfile = ({
[
[t("stats.wins"), t(tntgames.tntRun.wins)],
[t("stats.wlr"), t(tntgames.tntRun.wlr)],
[t("stats.bestTime"), formatTime(tntgames.tntRun.record)],
[t("stats.bestTime"), formatTimeWithSeconds(tntgames.tntRun.record)],
] :
[
[t("stats.wins"), t(tntgames.tntRun.wins)],
Expand Down Expand Up @@ -104,7 +107,7 @@ export const TNTGamesProfile = ({
<Table.td title={t("stats.potionsSplashed")} value={t(tntgames.tntRun.potionsSplashed)} color="§5" />
<Table.td title={t("stats.blocksRan")} value={t(tntgames.tntRun.blocksRan)} color="§b" />
<Historical.exclude time={time}>
<Table.td title={t("stats.bestTime")} value={formatTime(tntgames.tntRun.record)} color="§e" />
<Table.td title={t("stats.bestTime")} value={formatTimeWithSeconds(tntgames.tntRun.record)} color="§e" />
</Historical.exclude>
</Table.tr>
</>
Expand All @@ -124,7 +127,7 @@ export const TNTGamesProfile = ({
<Historical.exclude time={time}>
<Table.tr>
<Table.td title={t("stats.wins")} value={t(tntgames.pvpRun.wins)} color="§a" />
<Table.td title={t("stats.bestTime")} value={formatTime(tntgames.pvpRun.record)} color="§e" />
<Table.td title={t("stats.bestTime")} value={formatTimeWithSeconds(tntgames.pvpRun.record)} color="§e" />
</Table.tr>
</Historical.exclude>
</>
Expand Down
6 changes: 5 additions & 1 deletion apps/discord-bot/src/commands/warlords/warlords.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export const WarlordsProfile = ({
sidebar.push([t("stats.class"), prettify(warlords.class), "§e"]);
const clazz = warlords.class as "mage" | "warrior" | "paladin" | "shaman";
// Verify that the cast is correct and the class is a valid class
if (clazz in warlords && typeof warlords[clazz] === "object") sidebar.push([t("stats.spec"), prettify(warlords[clazz].specification), "§a"]);
if (clazz in warlords && typeof warlords[clazz] === "object")
sidebar.push(
[t("stats.spec"), prettify(warlords[clazz].specification), "§a"],
[t("stats.level"), t(warlords[clazz].level), "§a"]
);
}

let table: JSX.Element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import type { CaptureTheWool } from "@statsify/schemas";
import type { LocalizeFunction } from "@statsify/discord";
import type { ProfileTime } from "#commands/base.hypixel-command";

const formatTimeWithSeconds = (time: number) => formatTime(time, { entries: 3 });

interface CaptureTheWoolTableProps {
captureTheWool: CaptureTheWool;
t: LocalizeFunction;
Expand Down Expand Up @@ -54,21 +56,21 @@ export const CaptureTheWoolTable = ({ captureTheWool, t, time }: CaptureTheWoolT
<If condition={captureTheWool.fastestWin > 0}>
<Table.td
title={t("stats.fastestWin")}
value={formatTime(captureTheWool.fastestWin)}
value={formatTimeWithSeconds(captureTheWool.fastestWin)}
color="§e"
/>
</If>
<If condition={captureTheWool.fastestWoolCapture > 0}>
<Table.td
title={t("stats.fastestWoolCapture")}
value={formatTime(captureTheWool.fastestWoolCapture)}
value={formatTimeWithSeconds(captureTheWool.fastestWoolCapture)}
color="§6"
/>
</If>
<If condition={captureTheWool.longestGame > 0}>
<Table.td
title={t("stats.longestGame")}
value={formatTime(captureTheWool.longestGame)}
value={formatTimeWithSeconds(captureTheWool.longestGame)}
color="§d"
/>
</If>
Expand Down
Loading
Loading