From da0f90f5d79497f88a9cd35b19410b8d398c1159 Mon Sep 17 00:00:00 2001 From: Nuno Duque Nunes Date: Sat, 20 Jun 2026 03:28:22 +0100 Subject: [PATCH] fix char autocomplete, /tg char active legacy code --- src/handlers/autocomplete.ts | 12 ++++++------ src/subcommands/char/active.ts | 8 +++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/handlers/autocomplete.ts b/src/handlers/autocomplete.ts index 59fdbe7..cf105b4 100644 --- a/src/handlers/autocomplete.ts +++ b/src/handlers/autocomplete.ts @@ -45,8 +45,8 @@ async function autocompleteCharNames( .filter((c) => !nation || c.nation === nation) .filter((c) => c.name.toLowerCase().includes(focused.toLowerCase())) .map((c) => { - const nationEmoji = c.nation ? (NATION_UNICODE[c.nation] || c.nation) : ""; - return { name: `${c.class} ${c.level} ${c.name} ${nationEmoji}`.trim(), value: c.name }; + const classKey = typeof c.class === "object" ? c.class?.key : c.class; + return { name: `${classKey} ${c.level} ${c.name} [${c.nation}]`.trim(), value: c.name }; }) .slice(0, 25); return interaction.respond(results); @@ -56,18 +56,18 @@ async function autocompleteCharNames( // Own chars const ownChars = getCharacters(user.userKey).map((c) => { - const nationEmoji = c.nation ? (Emoji.nation(c.nation) || c.nation) : ""; + const classKey = typeof c.class === "object" ? c.class?.key : c.class; return { - name: `${c.class} ${c.level} ${c.name} ${nationEmoji}`.trim(), + name: `${classKey} ${c.level} ${c.name} [${c.nation}]`.trim(), value: c.name, }; }); // Shared chars const sharedChars = CharacterRegistry.sharedWith(user.userKey).map(({ char }) => { - const nationEmoji = char.nation ? (Emoji.nation(char.nation) || char.nation) : ""; + const classKey = typeof char.class === "object" ? char.class?.key : char.class; return { - name: `${char.class} ${char.level} ${char.name} 🔗 ${nationEmoji}`.trim(), + name: `${classKey} ${char.level} ${char.name} [${char.nation}] 🔗`.trim(), value: char.name, }; }); diff --git a/src/subcommands/char/active.ts b/src/subcommands/char/active.ts index dbaaa15..2489670 100644 --- a/src/subcommands/char/active.ts +++ b/src/subcommands/char/active.ts @@ -1,10 +1,8 @@ import { ChatInputCommandInteraction, TextChannel } from "discord.js"; import { Config } from "../../systems/config"; import { resolveUser, hasOfficerRole } from "../../systems/users"; -import { getCharacterByName, getActiveCharacter } from "../../systems/characters"; -import { addPendingRequest, setSessionBorrow, sendBorrowRequestDM, canUseCharacter } from "../../systems/borrow"; -import { polls, updatePollMessage } from "../../systems/poll"; import { replyAndDelete } from "../../utils"; +import { Emoji } from "@systems/emojis"; export async function handleCharActive(interaction: ChatInputCommandInteraction): Promise { const nameArg = interaction.options.getString("name"); @@ -22,8 +20,8 @@ export async function handleCharActive(interaction: ChatInputCommandInteraction) const { char, borrowedFrom } = getEffectiveCharacter(targetKey); if (!char) return void replyAndDelete(interaction, `❌ No active character found for **${targetKey}**.`); - const { getClassEmoji } = require("../../systems/emojis"); - const classEmoji = getClassEmoji(char.class) || char.class; + const classKey = typeof char.class === "object" ? char.class?.key : char.class; + const classEmoji = Emoji.class(classKey) || classKey; const borrowed = borrowedFrom ? ` *(shared by ${borrowedFrom})*` : ""; return void replyAndDelete(interaction, `${classEmoji} ${char.level} ${char.name}${borrowed}`); } \ No newline at end of file