feat: Enable Components V2, use user mentions, and enhance transaction log display in terminal service.

This commit is contained in:
syntaxbullet
2025-12-24 18:07:50 +01:00
parent 6d725b73db
commit 8c28fe60fc

View File

@@ -69,11 +69,14 @@ export const terminalService = {
const containers = await terminalService.buildMessage(); const containers = await terminalService.buildMessage();
// Should be using 'components' for containers // Components V2 requires the IsComponentsV2 flag and no content/embeds
// Disable allowedMentions to prevent pings from the dashboard
await message.edit({ await message.edit({
content: null, content: null,
embeds: null as any,
components: containers as any, components: containers as any,
flags: MessageFlags.IsComponentsV2 flags: MessageFlags.IsComponentsV2,
allowedMentions: { parse: [] }
}); });
} catch (error) { } catch (error) {
@@ -93,7 +96,7 @@ export const terminalService = {
const formatUser = (u: typeof users.$inferSelect, i: number) => { const formatUser = (u: typeof users.$inferSelect, i: number) => {
const star = i === 0 ? "🌟" : i === 1 ? "⭐" : "✨"; const star = i === 0 ? "🌟" : i === 1 ? "⭐" : "✨";
return `${star} **${u.username}**`; return `${star} <@${u.id}>`;
}; };
const levelText = topLevels.map((u, i) => `> ${formatUser(u, i)} • Lvl ${u.level}`).join("\n") || "> *The sky is empty...*"; const levelText = topLevels.map((u, i) => `> ${formatUser(u, i)} • Lvl ${u.level}`).join("\n") || "> *The sky is empty...*";
@@ -114,7 +117,6 @@ export const terminalService = {
// --- CONTAINER 1: Header --- // --- CONTAINER 1: Header ---
const headerContainer = new ContainerBuilder() const headerContainer = new ContainerBuilder()
.setAccentColor(0x00ff99)
.addTextDisplayComponents( .addTextDisplayComponents(
new TextDisplayBuilder().setContent("# 🌌 AURORA OBSERVATORY"), new TextDisplayBuilder().setContent("# 🌌 AURORA OBSERVATORY"),
new TextDisplayBuilder().setContent("*Current Moon Phase: Waxing Crescent 🌒*") new TextDisplayBuilder().setContent("*Current Moon Phase: Waxing Crescent 🌒*")
@@ -129,7 +131,7 @@ export const terminalService = {
} else if (recentDrops.length > 0 && recentDrops[0]) { } else if (recentDrops.length > 0 && recentDrops[0]) {
const drop = recentDrops[0]; const drop = recentDrops[0];
const claimer = allUsers.find(u => u.id === drop.claimedBy); const claimer = allUsers.find(u => u.id === drop.claimedBy);
phenomenaContent = `\n**RECENT EVENT**\nStar yielded \`${drop.rewardAmount} ${drop.currency}\` to **${claimer?.username || 'Unknown'}**`; phenomenaContent = `\n**RECENT EVENT**\nStar yielded \`${drop.rewardAmount} ${drop.currency}\` to ${claimer ? `<@${claimer.id}>` : '**Unknown**'}`;
} }
const logContainer = new ContainerBuilder() const logContainer = new ContainerBuilder()
@@ -158,7 +160,11 @@ export const terminalService = {
if (tx.type.includes("LOOT")) icon = "🌠"; if (tx.type.includes("LOOT")) icon = "🌠";
if (tx.type.includes("GIFT")) icon = "🌕"; if (tx.type.includes("GIFT")) icon = "🌕";
const user = allUsers.find(u => u.id === tx.userId); const user = allUsers.find(u => u.id === tx.userId);
return `\`[<t:${time}:T>]\` ${icon} **${user?.username || 'Unknown'}**: ${tx.description}`;
// the description might contain a channel id all the way at the end
const channelId = tx.description?.split(" ").pop() || "";
const text = tx.description?.replace(channelId, "<#" + channelId + ">") || "";
return `<t:${time}:F> ${icon} ${user ? `<@${user.id}>` : '**Unknown**'}: ${text}`;
}); });
const echoesContainer = new ContainerBuilder() const echoesContainer = new ContainerBuilder()