diff --git a/packages/oaf/src/utils.ts b/packages/oaf/src/utils.ts index c6c5b5e..6dfad58 100644 --- a/packages/oaf/src/utils.ts +++ b/packages/oaf/src/utils.ts @@ -123,14 +123,22 @@ export function titleCase(title: string) { } export function formatPlayer(player: Player | undefined, backupId?: number) { - const discordId = player?.discordId; - return discordId - ? `${userMention(discordId)}${hyperlink( - "👤", - `https://www.kingdomofloathing.com/showplayer.php?who=${player.playerId}`, - player.playerName, - )}` - : player?.playerName || `Player #${backupId}` || "Unknown player"; + return [ + player?.playerName ?? "Unknown Username", + ...(player?.playerId + ? [ + `(#${player.playerId})`, + hyperlink( + "👤", + `https://www.kingdomofloathing.com/showplayer.php?who=${player.playerId}`, + player.playerName, + ), + ] + : backupId + ? [`(#${backupId})`] + : []), + ...(player?.discordId ? userMention(player.discordId) : ""), + ].join(" "); } export function ensureArray(v: T | T[]) {