import { createCommand } from "@shared/lib/utils"; import { SlashCommandBuilder } from "discord.js"; import { economyService } from "@shared/modules/economy/economy.service"; import { createErrorEmbed, createSuccessEmbed } from "@lib/embeds"; import { UserError } from "@/lib/errors"; export const daily = createCommand({ data: new SlashCommandBuilder() .setName("daily") .setDescription("Claim your daily reward"), execute: async (interaction) => { try { const result = await economyService.claimDaily(interaction.user.id); const embed = createSuccessEmbed(`You claimed ** ${result.amount}** Astral Units!${result.isWeekly ? `\nšŸŽ‰ **Weekly Bonus!** +${result.weeklyBonus} extra!` : ''}`, "šŸ’° Daily Reward Claimed!") .addFields( { name: "Streak", value: `šŸ”„ ${result.streak} days`, inline: true }, { name: "Weekly Progress", value: `${"🟩".repeat(result.streak % 7 || 7)}${"⬜".repeat(7 - (result.streak % 7 || 7))} (${result.streak % 7 || 7}/7)`, inline: true }, { name: "Next Reward", value: ` `, inline: true } ) .setColor("Gold"); await interaction.reply({ embeds: [embed] }); } catch (error: any) { if (error instanceof UserError) { await interaction.reply({ embeds: [createErrorEmbed(error.message)], ephemeral: true }); } else { console.error("Error claiming daily:", error); await interaction.reply({ embeds: [createErrorEmbed("An unexpected error occurred.")], ephemeral: true }); } } } });