refactor: add quest view layer
Create quest.view.ts with UI logic extracted from quests command: - getQuestListEmbed() for quest log display - formatQuestRewards() helper for reward formatting - getQuestStatus() helper for status display Updated quests.ts to use view functions instead of inline embed building.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { createCommand } from "@/lib/utils";
|
||||
import { SlashCommandBuilder, MessageFlags } from "discord.js";
|
||||
import { questService } from "@/modules/quest/quest.service";
|
||||
import { createWarningEmbed, createBaseEmbed } from "@lib/embeds";
|
||||
import { createWarningEmbed } from "@lib/embeds";
|
||||
import { getQuestListEmbed } from "@/modules/quest/quest.view";
|
||||
|
||||
export const quests = createCommand({
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -17,21 +18,7 @@ export const quests = createCommand({
|
||||
return;
|
||||
}
|
||||
|
||||
const embed = createBaseEmbed("📜 Quest Log", undefined, "Blue");
|
||||
|
||||
userQuests.forEach(entry => {
|
||||
const status = entry.completedAt ? "✅ Completed" : "In Progress";
|
||||
const rewards = entry.quest.rewards as { xp?: number, balance?: number };
|
||||
const rewardStr = [];
|
||||
if (rewards?.xp) rewardStr.push(`${rewards.xp} XP`);
|
||||
if (rewards?.balance) rewardStr.push(`${rewards.balance} 🪙`);
|
||||
|
||||
embed.addFields({
|
||||
name: `${entry.quest.name} (${status})`,
|
||||
value: `${entry.quest.description}\n**Rewards:** ${rewardStr.join(", ")}\n**Progress:** ${entry.progress}%`,
|
||||
inline: false
|
||||
});
|
||||
});
|
||||
const embed = getQuestListEmbed(userQuests);
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user