fix char autocomplete, /tg char active legacy code
This commit is contained in:
parent
9e8877483d
commit
da0f90f5d7
2 changed files with 9 additions and 11 deletions
|
|
@ -45,8 +45,8 @@ async function autocompleteCharNames(
|
||||||
.filter((c) => !nation || c.nation === nation)
|
.filter((c) => !nation || c.nation === nation)
|
||||||
.filter((c) => c.name.toLowerCase().includes(focused.toLowerCase()))
|
.filter((c) => c.name.toLowerCase().includes(focused.toLowerCase()))
|
||||||
.map((c) => {
|
.map((c) => {
|
||||||
const nationEmoji = c.nation ? (NATION_UNICODE[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(), value: c.name };
|
return { name: `${classKey} ${c.level} ${c.name} [${c.nation}]`.trim(), value: c.name };
|
||||||
})
|
})
|
||||||
.slice(0, 25);
|
.slice(0, 25);
|
||||||
return interaction.respond(results);
|
return interaction.respond(results);
|
||||||
|
|
@ -56,18 +56,18 @@ async function autocompleteCharNames(
|
||||||
|
|
||||||
// Own chars
|
// Own chars
|
||||||
const ownChars = getCharacters(user.userKey).map((c) => {
|
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 {
|
return {
|
||||||
name: `${c.class} ${c.level} ${c.name} ${nationEmoji}`.trim(),
|
name: `${classKey} ${c.level} ${c.name} [${c.nation}]`.trim(),
|
||||||
value: c.name,
|
value: c.name,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// Shared chars
|
// Shared chars
|
||||||
const sharedChars = CharacterRegistry.sharedWith(user.userKey).map(({ char }) => {
|
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 {
|
return {
|
||||||
name: `${char.class} ${char.level} ${char.name} 🔗 ${nationEmoji}`.trim(),
|
name: `${classKey} ${char.level} ${char.name} [${char.nation}] 🔗`.trim(),
|
||||||
value: char.name,
|
value: char.name,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import { ChatInputCommandInteraction, TextChannel } from "discord.js";
|
import { ChatInputCommandInteraction, TextChannel } from "discord.js";
|
||||||
import { Config } from "../../systems/config";
|
import { Config } from "../../systems/config";
|
||||||
import { resolveUser, hasOfficerRole } from "../../systems/users";
|
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 { replyAndDelete } from "../../utils";
|
||||||
|
import { Emoji } from "@systems/emojis";
|
||||||
|
|
||||||
export async function handleCharActive(interaction: ChatInputCommandInteraction): Promise<void> {
|
export async function handleCharActive(interaction: ChatInputCommandInteraction): Promise<void> {
|
||||||
const nameArg = interaction.options.getString("name");
|
const nameArg = interaction.options.getString("name");
|
||||||
|
|
@ -22,8 +20,8 @@ export async function handleCharActive(interaction: ChatInputCommandInteraction)
|
||||||
const { char, borrowedFrom } = getEffectiveCharacter(targetKey);
|
const { char, borrowedFrom } = getEffectiveCharacter(targetKey);
|
||||||
if (!char) return void replyAndDelete(interaction, `❌ No active character found for **${targetKey}**.`);
|
if (!char) return void replyAndDelete(interaction, `❌ No active character found for **${targetKey}**.`);
|
||||||
|
|
||||||
const { getClassEmoji } = require("../../systems/emojis");
|
const classKey = typeof char.class === "object" ? char.class?.key : char.class;
|
||||||
const classEmoji = getClassEmoji(char.class) || char.class;
|
const classEmoji = Emoji.class(classKey) || classKey;
|
||||||
const borrowed = borrowedFrom ? ` *(shared by ${borrowedFrom})*` : "";
|
const borrowed = borrowedFrom ? ` *(shared by ${borrowedFrom})*` : "";
|
||||||
return void replyAndDelete(interaction, `${classEmoji} ${char.level} ${char.name}${borrowed}`);
|
return void replyAndDelete(interaction, `${classEmoji} ${char.level} ${char.name}${borrowed}`);
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue