diff --git a/src/commands/economy/exam.ts b/src/commands/economy/exam.ts index d7a3159..425240a 100644 --- a/src/commands/economy/exam.ts +++ b/src/commands/economy/exam.ts @@ -41,8 +41,9 @@ export const exam = createCommand({ // 2. First Run Logic if (!timer) { // Set exam day to today - const nextWeek = new Date(now); - nextWeek.setDate(now.getDate() + 7); + const nextExamDate = new Date(now); + nextExamDate.setDate(now.getDate() + 7); + const nextExamTimestamp = Math.floor(nextExamDate.getTime() / 1000); const metadata: ExamMetadata = { examDay: currentDay, @@ -53,14 +54,14 @@ export const exam = createCommand({ userId: user.id, type: EXAM_TIMER_TYPE, key: EXAM_TIMER_KEY, - expiresAt: nextWeek, + expiresAt: nextExamDate, metadata: metadata }); await interaction.editReply({ embeds: [createSuccessEmbed( - `You have registered for the exam! Your exam day is **${DAYS[currentDay]}**.\n` + - `Come back next week on **${DAYS[currentDay]}** to take your first exam and earn rewards based on your XP gain!`, + `You have registered for the exam! Your exam day is **${DAYS[currentDay]}** (Server Time).\n` + + `Come back on () to take your first exam!`, "Exam Registration Successful" )] }); @@ -74,13 +75,12 @@ export const exam = createCommand({ if (now < new Date(timer.expiresAt)) { // Calculate time remaining const expiresAt = new Date(timer.expiresAt); - // Simple formatting const timestamp = Math.floor(expiresAt.getTime() / 1000); await interaction.editReply({ embeds: [createErrorEmbed( `You have already taken your exam for this week (or are waiting for your first week to pass).\n` + - `Next exam available: (${DAYS[examDay]})` + `Next exam available: ()` )] }); return; @@ -88,11 +88,13 @@ export const exam = createCommand({ // 4. Day Check if (currentDay !== examDay) { - // "If not executed on same weekday... we do not reward" - // Consume the attempt (reset timer) but give 0 reward. + // Calculate next correct exam day to correct the schedule + let daysUntil = (examDay - currentDay + 7) % 7; + if (daysUntil === 0) daysUntil = 7; - const nextWeek = new Date(now); - nextWeek.setDate(now.getDate() + 7); + const nextExamDate = new Date(now); + nextExamDate.setDate(now.getDate() + daysUntil); + const nextExamTimestamp = Math.floor(nextExamDate.getTime() / 1000); const newMetadata: ExamMetadata = { examDay: examDay, @@ -101,7 +103,7 @@ export const exam = createCommand({ await DrizzleClient.update(userTimers) .set({ - expiresAt: nextWeek, + expiresAt: nextExamDate, metadata: newMetadata }) .where(and( @@ -112,8 +114,9 @@ export const exam = createCommand({ await interaction.editReply({ embeds: [createErrorEmbed( - `You missed your exam day! Your exam is on **${DAYS[examDay]}**, but today is ${DAYS[currentDay]}.\n` + - `You verify your attendance but score a **0**. Come back next **${DAYS[examDay]}**!`, + `You missed your exam day! Your exam day is **${DAYS[examDay]}** (Server Time).\n` + + `You verify your attendance but score a **0**.\n` + + `Your next exam opportunity is: ()`, "Exam Failed" )] }); @@ -138,8 +141,9 @@ export const exam = createCommand({ } // 6. Update State - const nextWeek = new Date(now); - nextWeek.setDate(now.getDate() + 7); + const nextExamDate = new Date(now); + nextExamDate.setDate(now.getDate() + 7); + const nextExamTimestamp = Math.floor(nextExamDate.getTime() / 1000); const newMetadata: ExamMetadata = { examDay: examDay, @@ -150,7 +154,7 @@ export const exam = createCommand({ // Update Timer await tx.update(userTimers) .set({ - expiresAt: nextWeek, + expiresAt: nextExamDate, metadata: newMetadata }) .where(and( @@ -174,7 +178,7 @@ export const exam = createCommand({ `**XP Gained:** ${diff.toString()}\n` + `**Multiplier:** x${multiplier.toFixed(2)}\n` + `**Reward:** ${reward.toString()} Currency\n\n` + - `See you next week on **${DAYS[examDay]}**!`, + `See you next week: `, "Exam Passed!" )] }); diff --git a/src/commands/economy/pay.ts b/src/commands/economy/pay.ts index 3085b6f..34a7fe5 100644 --- a/src/commands/economy/pay.ts +++ b/src/commands/economy/pay.ts @@ -51,11 +51,11 @@ export const pay = createCommand({ const embed = new EmbedBuilder() .setTitle("💸 Transfer Successful") - .setDescription(`Successfully sent ** ${amount}** Astral Units to < @${targetUser.id}>.`) + .setDescription(`Successfully sent ** ${amount}** Astral Units to <@${targetUser.id}>.`) .setColor("Green") .setTimestamp(); - await interaction.editReply({ embeds: [embed] }); + await interaction.editReply({ embeds: [embed], content: `<@${receiverId}>` }); } catch (error: any) { if (error instanceof UserError) {