fix format.char()

This commit is contained in:
Nuno Duque Nunes 2026-06-11 04:44:20 +01:00
parent ed9e7209d0
commit 347d1423fc

View file

@ -1,4 +1,4 @@
import { Character, ClassKey, CharacterClass, Nation } from "@src/types"; import { Character, CharacterClass, Nation } from "@src/types";
import { Emoji } from "@systems/emojis"; import { Emoji } from "@systems/emojis";
import { WRankEntry } from "@systems/wrank"; import { WRankEntry } from "@systems/wrank";
@ -18,13 +18,11 @@ function charButton(c: Character, options?: { shared?: boolean }): string {
* Format a character for display in embeds and messages. * Format a character for display in embeds and messages.
* Output: <:class:> 79 «Flash» * Output: <:class:> 79 «Flash»
*/ */
function char( function char(c: Character, options?: CharDisplayOptions): string {
c: { class: ClassKey|CharacterClass; level: number; name: string },
options?: CharDisplayOptions
): string {
const showEmoji = options?.emoji ?? true; const showEmoji = options?.emoji ?? true;
const showLevel = options?.level ?? true; const showLevel = options?.level ?? true;
const classStr = showEmoji ? (Emoji.class(c.class) || c.class) : c.class; const classKey = c.class.key;
const classStr = showEmoji ? (Emoji.class(classKey) || classKey) : classKey;
const levelStr = showLevel ? `${c.level} ` : ""; const levelStr = showLevel ? `${c.level} ` : "";
return `${classStr} ${levelStr}${c.name}`.trim(); return `${classStr} ${levelStr}${c.name}`.trim();
} }