diff --git a/ACTUALIZACIONES_FINAL.md b/README/ACTUALIZACIONES_FINAL.md similarity index 100% rename from ACTUALIZACIONES_FINAL.md rename to README/ACTUALIZACIONES_FINAL.md diff --git a/CREACION_DE_CONTENIDO.md b/README/CREACION_DE_CONTENIDO.md similarity index 100% rename from CREACION_DE_CONTENIDO.md rename to README/CREACION_DE_CONTENIDO.md diff --git a/FIX_USER_CREATION.md b/README/FIX_USER_CREATION.md similarity index 100% rename from FIX_USER_CREATION.md rename to README/FIX_USER_CREATION.md diff --git a/GUIA_DE_USUARIO.md b/README/GUIA_DE_USUARIO.md similarity index 100% rename from GUIA_DE_USUARIO.md rename to README/GUIA_DE_USUARIO.md diff --git a/MEMORY_OPTIMIZATION.md b/README/MEMORY_OPTIMIZATION.md similarity index 100% rename from MEMORY_OPTIMIZATION.md rename to README/MEMORY_OPTIMIZATION.md diff --git a/Mas Ejemplos.md b/README/Mas Ejemplos.md similarity index 100% rename from Mas Ejemplos.md rename to README/Mas Ejemplos.md diff --git a/src/server/README.md b/README/README.md similarity index 100% rename from src/server/README.md rename to README/README.md diff --git a/RESUMEN_CAMBIOS.md b/README/RESUMEN_CAMBIOS.md similarity index 100% rename from RESUMEN_CAMBIOS.md rename to README/RESUMEN_CAMBIOS.md diff --git a/SUGERENCIAS_Y_MEJORAS.md b/README/SUGERENCIAS_Y_MEJORAS.md similarity index 100% rename from SUGERENCIAS_Y_MEJORAS.md rename to README/SUGERENCIAS_Y_MEJORAS.md diff --git a/src/commands/messages/game/racha.ts b/src/commands/messages/game/racha.ts index 5e85f02..0a7bd61 100644 --- a/src/commands/messages/game/racha.ts +++ b/src/commands/messages/game/racha.ts @@ -1,42 +1,48 @@ -import type { CommandMessage } from '../../../core/types/commands'; -import type Amayo from '../../../core/client'; -import { getStreakInfo, updateStreak } from '../../../game/streaks/service'; -import type { TextBasedChannel } from 'discord.js'; -import { fetchItemBasics, formatItemLabel } from './_helpers'; +import type { CommandMessage } from "../../../core/types/commands"; +import type Amayo from "../../../core/client"; +import { getStreakInfo, updateStreak } from "../../../game/streaks/service"; +import type { TextBasedChannel } from "discord.js"; +import { fetchItemBasics, formatItemLabel, sendDisplayReply } from "./_helpers"; export const command: CommandMessage = { - name: 'racha', - type: 'message', - aliases: ['streak', 'daily'], + name: "racha", + type: "message", + aliases: ["streak", "daily"], cooldown: 10, - description: 'Ver tu racha diaria y reclamar recompensa', - usage: 'racha', + description: "Ver tu racha diaria y reclamar recompensa", + usage: "racha", run: async (message, args, client: Amayo) => { try { const userId = message.author.id; const guildId = message.guild!.id; // Actualizar racha - const { streak, newDay, rewards, daysIncreased } = await updateStreak(userId, guildId); + const { streak, newDay, rewards, daysIncreased } = await updateStreak( + userId, + guildId + ); // Construir componentes const components: any[] = [ { type: 10, - content: `# 🔥 Racha Diaria de ${message.author.username}` + content: `# 🔥 Racha Diaria de ${message.author.username}`, }, { type: 14, divider: true }, { type: 9, - components: [{ - type: 10, - content: `**📊 ESTADÍSTICAS**\n` + - `🔥 Racha Actual: **${streak.currentStreak}** días\n` + - `⭐ Mejor Racha: **${streak.longestStreak}** días\n` + - `📅 Días Activos: **${streak.totalDaysActive}** días` - }] + components: [ + { + type: 10, + content: + `**📊 ESTADÍSTICAS**\n` + + `🔥 Racha Actual: **${streak.currentStreak}** días\n` + + `⭐ Mejor Racha: **${streak.longestStreak}** días\n` + + `📅 Días Activos: **${streak.totalDaysActive}** días`, + }, + ], }, - { type: 14, spacing: 1 } + { type: 14, spacing: 1 }, ]; // Mensaje de estado @@ -44,84 +50,97 @@ export const command: CommandMessage = { if (daysIncreased) { components.push({ type: 9, - components: [{ - type: 10, - content: `**✅ ¡RACHA INCREMENTADA!**\nHas mantenido tu racha por **${streak.currentStreak}** días seguidos.` - }] + components: [ + { + type: 10, + content: `**✅ ¡RACHA INCREMENTADA!**\nHas mantenido tu racha por **${streak.currentStreak}** días seguidos.`, + }, + ], }); } else { components.push({ type: 9, - components: [{ - type: 10, - content: `**⚠️ RACHA REINICIADA**\nPasó más de un día sin actividad. Tu racha se ha reiniciado.` - }] + components: [ + { + type: 10, + content: `**⚠️ RACHA REINICIADA**\nPasó más de un día sin actividad. Tu racha se ha reiniciado.`, + }, + ], }); } // Mostrar recompensas if (rewards) { - let rewardsText = '**🎁 RECOMPENSA DEL DÍA**\n'; - if (rewards.coins) rewardsText += `💰 **${rewards.coins.toLocaleString()}** monedas\n`; + let rewardsText = "**🎁 RECOMPENSA DEL DÍA**\n"; + if (rewards.coins) + rewardsText += `💰 **${rewards.coins.toLocaleString()}** monedas\n`; if (rewards.items && rewards.items.length) { - const basics = await fetchItemBasics(guildId, rewards.items.map((item) => item.key)); - rewards.items.forEach(item => { - const info = basics.get(item.key) ?? { key: item.key, name: null, icon: null }; + const basics = await fetchItemBasics( + guildId, + rewards.items.map((item) => item.key) + ); + rewards.items.forEach((item) => { + const info = basics.get(item.key) ?? { + key: item.key, + name: null, + icon: null, + }; const label = formatItemLabel(info, { bold: true }); rewardsText += `${label} ×${item.quantity}\n`; }); } - + components.push({ type: 14, spacing: 1 }); components.push({ type: 9, - components: [{ - type: 10, - content: rewardsText - }] + components: [ + { + type: 10, + content: rewardsText, + }, + ], }); } } else { components.push({ type: 9, - components: [{ - type: 10, - content: `**ℹ️ YA RECLAMASTE HOY**\nYa has reclamado tu recompensa diaria. Vuelve mañana para continuar tu racha.` - }] + components: [ + { + type: 10, + content: `**ℹ️ YA RECLAMASTE HOY**\nYa has reclamado tu recompensa diaria. Vuelve mañana para continuar tu racha.`, + }, + ], }); } // Próximos hitos const milestones = [3, 7, 14, 30, 60, 90, 180, 365]; - const nextMilestone = milestones.find(m => m > streak.currentStreak); - + const nextMilestone = milestones.find((m) => m > streak.currentStreak); + if (nextMilestone) { const remaining = nextMilestone - streak.currentStreak; components.push({ type: 14, spacing: 1 }); components.push({ type: 9, - components: [{ - type: 10, - content: `**🎯 PRÓXIMO HITO**\nFaltan **${remaining}** días para alcanzar el día **${nextMilestone}**` - }] + components: [ + { + type: 10, + content: `**🎯 PRÓXIMO HITO**\nFaltan **${remaining}** días para alcanzar el día **${nextMilestone}**`, + }, + ], }); } const display = { type: 17, - accent_color: daysIncreased ? 0x00FF00 : 0xFFA500, - components + accent_color: daysIncreased ? 0x00ff00 : 0xffa500, + components, }; - const channel = message.channel as TextBasedChannel & { send: Function }; - await (channel.send as any)({ - display, - flags: 32768, - reply: { messageReference: message.id } - }); + await sendDisplayReply(message, display); } catch (error) { - console.error('Error en comando racha:', error); - await message.reply('❌ Error al obtener tu racha diaria.'); + console.error("Error en comando racha:", error); + await message.reply("❌ Error al obtener tu racha diaria."); } - } + }, }; diff --git a/src/server/public/index.html b/src/server/public/index.html index 45538b9..45337aa 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -6,7 +6,7 @@