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"; export async function handleCharActive(interaction: ChatInputCommandInteraction): Promise { const nameArg = interaction.options.getString("name"); const group = interaction.options.getSubcommandGroup(false); const sub = interaction.options.getSubcommand(); const member = await interaction.guild!.members.fetch(interaction.user.id); const isOfficer = hasOfficerRole(member, Config.get({ section: "roles", key: "officer" })); if (nameArg && !isOfficer) { return void replyAndDelete(interaction, "❌ Only officers can check other players' active character."); } const targetKey = nameArg ?? (await resolveUser(member)).userKey; if (!targetKey) return void replyAndDelete(interaction, "❌ You are not registered in the system."); const { getEffectiveCharacter } = require("../../systems/borrow"); 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 borrowed = borrowedFrom ? ` *(shared by ${borrowedFrom})*` : ""; return void replyAndDelete(interaction, `${classEmoji} ${char.level} ${char.name}${borrowed}`); }