Files
AuroraBot-discord/src/commands/quest/quests.ts

42 lines
1.6 KiB
TypeScript

import { createCommand } from "@/lib/utils";
import { SlashCommandBuilder, EmbedBuilder, MessageFlags } from "discord.js";
import { questService } from "@/modules/quest/quest.service";
import { createWarningEmbed } from "@lib/embeds";
export const quests = createCommand({
data: new SlashCommandBuilder()
.setName("quests")
.setDescription("View your active quests"),
execute: async (interaction) => {
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
const userQuests = await questService.getUserQuests(interaction.user.id);
if (!userQuests || userQuests.length === 0) {
await interaction.editReply({ embeds: [createWarningEmbed("You have no active quests.", "Quest Log")] });
return;
}
const embed = new EmbedBuilder()
.setTitle("📜 Quest Log")
.setColor("Blue")
.setTimestamp();
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
});
});
await interaction.editReply({ embeds: [embed] });
}
});