From d842a4ebd5d5f78b9766979dd47ccabbaca1b386 Mon Sep 17 00:00:00 2001 From: shni Date: Wed, 8 Oct 2025 22:51:15 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20mejorar=20la=20presentaci=C3=B3n=20de?= =?UTF-8?q?=20estad=C3=ADsticas=20y=20mensajes=20de=20error=20en=20los=20c?= =?UTF-8?q?omandos=20de=20racha,=20estad=C3=ADsticas=20y=20tienda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/messages/game/racha.ts | 27 +++++---- src/commands/messages/game/stats.ts | 89 ++++++++++++++++++---------- src/commands/messages/game/tienda.ts | 12 ++-- 3 files changed, 80 insertions(+), 48 deletions(-) diff --git a/src/commands/messages/game/racha.ts b/src/commands/messages/game/racha.ts index 4d46244..0520533 100644 --- a/src/commands/messages/game/racha.ts +++ b/src/commands/messages/game/racha.ts @@ -29,13 +29,15 @@ export const command: CommandMessage = { // Construir bloques de display (evitando type:9 sin accessory) const blocks: any[] = [ - textBlock(`# 🔥 Racha Diaria de ${message.author.username}`), + textBlock( + `## Racha diaria de ${message.author.username}` + ), dividerBlock(), textBlock( - `**📊 ESTADÍSTICAS**\n` + - `🔥 Racha Actual: **${streak.currentStreak}** días\n` + - `⭐ Mejor Racha: **${streak.longestStreak}** días\n` + - `📅 Días Activos: **${streak.totalDaysActive}** días` + `**<:stats:1425689271788113991> ESTADÍSTICAS**\n` + + ` Racha Actual: **${streak.currentStreak}** días\n` + + ` Mejor Racha: **${streak.longestStreak}** días\n` + + `<:events:1425691310194561106> Días Activos: **${streak.totalDaysActive}** días` ), dividerBlock({ spacing: 1 }), ]; @@ -45,22 +47,23 @@ export const command: CommandMessage = { if (daysIncreased) { blocks.push( textBlock( - `**✅ ¡RACHA INCREMENTADA!**\nHas mantenido tu racha por **${streak.currentStreak}** días seguidos.` + `**<:Sup_res:1420535051162095747> ¡RACHA INCREMENTADA!**\nHas mantenido tu racha por **${streak.currentStreak}** días seguidos.` ) ); } else { blocks.push( textBlock( - `**⚠️ RACHA REINICIADA**\nPasó más de un día sin actividad. Tu racha se ha reiniciado.` + `**<:Sup_urg:1420535068056748042> 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"; + let rewardsText = + "** RECOMPENSA DEL DÍA**\n"; if (rewards.coins) - rewardsText += `💰 **${rewards.coins.toLocaleString()}** monedas\n`; + rewardsText += `<:coin:1425667511013081169> **${rewards.coins.toLocaleString()}** monedas\n`; if (rewards.items && rewards.items.length) { const basics = await fetchItemBasics( guildId, @@ -83,7 +86,7 @@ export const command: CommandMessage = { } else { blocks.push( textBlock( - `**ℹ️ YA RECLAMASTE HOY**\nYa has reclamado tu recompensa diaria. Vuelve mañana para continuar tu racha.` + `**<:apin:1336533845541126174> YA RECLAMASTE HOY**\nYa has reclamado tu recompensa diaria. Vuelve mañana para continuar tu racha.` ) ); } @@ -107,7 +110,9 @@ export const command: CommandMessage = { await sendDisplayReply(message, display); } catch (error) { console.error("Error en comando racha:", error); - await message.reply("❌ Error al obtener tu racha diaria."); + await message.reply( + "<:Cross:1420535096208920576> Error al obtener tu racha diaria." + ); } }, }; diff --git a/src/commands/messages/game/stats.ts b/src/commands/messages/game/stats.ts index 6a50b45..331301d 100644 --- a/src/commands/messages/game/stats.ts +++ b/src/commands/messages/game/stats.ts @@ -1,15 +1,15 @@ -import type { CommandMessage } from '../../../core/types/commands'; -import type Amayo from '../../../core/client'; -import { getPlayerStatsFormatted } from '../../../game/stats/service'; -import type { TextBasedChannel } from 'discord.js'; +import type { CommandMessage } from "../../../core/types/commands"; +import type Amayo from "../../../core/client"; +import { getPlayerStatsFormatted } from "../../../game/stats/service"; +import type { TextBasedChannel } from "discord.js"; export const command: CommandMessage = { - name: 'stats', - type: 'message', - aliases: ['estadisticas', 'est'], + name: "stats", + type: "message", + aliases: ["estadisticas", "est"], cooldown: 5, - description: 'Ver estadísticas detalladas de un jugador', - usage: 'stats [@usuario]', + description: "Ver estadísticas detalladas de un jugador", + usage: "stats [@usuario]", run: async (message, args, client: Amayo) => { try { const guildId = message.guild!.id; @@ -20,52 +20,75 @@ export const command: CommandMessage = { const stats = await getPlayerStatsFormatted(userId, guildId); const formatValue = (value: unknown): string => { - if (typeof value === 'number') return value.toLocaleString(); - if (typeof value === 'bigint') return value.toString(); - if (typeof value === 'string') return value.trim() || '0'; - return value == null ? '0' : String(value); + if (typeof value === "number") return value.toLocaleString(); + if (typeof value === "bigint") return value.toString(); + if (typeof value === "string") return value.trim() || "0"; + return value == null ? "0" : String(value); }; const components: any[] = [ { type: 10, - content: `# 📊 Estadísticas de ${targetUser.username}` + content: `## <:stats:1425689271788113991> Estadísticas de ${targetUser.username}`, }, - { type: 14, divider: true } + { type: 14, divider: false, spacing: 1 }, ]; const addSection = (title: string, data?: Record) => { - if (!data || typeof data !== 'object') return; + if (!data || typeof data !== "object") return; const entries = Object.entries(data); - const lines = entries.map(([key, value]) => `${key}: **${formatValue(value)}**`); - const content = lines.length > 0 ? lines.join('\n') : 'Sin datos'; + const lines = entries.map( + ([key, value]) => `${key}: **${formatValue(value)}**` + ); + const content = lines.length > 0 ? lines.join("\n") : "Sin datos"; components.push({ type: 10, - content: `**${title}**\n${content}` + content: `**${title}**\n${content}`, }); components.push({ type: 14, divider: false, spacing: 1 }); }; - addSection('🎮 ACTIVIDADES', stats.activities as Record | undefined); - addSection('⚔️ COMBATE', stats.combat as Record | undefined); - addSection('💰 ECONOMÍA', stats.economy as Record | undefined); - addSection('📦 ITEMS', stats.items as Record | undefined); - addSection('🏆 RÉCORDS', stats.records as Record | undefined); + addSection( + "<:stats:1425689271788113991> ACTIVIDADES", + stats.activities as Record | undefined + ); + addSection( + "<:damage:1425670476449189998> COMBATE", + stats.combat as Record | undefined + ); + addSection( + "<:coin:1425667511013081169> ECONOMÍA", + stats.economy as Record | undefined + ); + addSection( + "<:emptybox:1425678700753588305> ITEMS", + stats.items as Record | undefined + ); + addSection( + " RÉCORDS", + stats.records as Record | undefined + ); // Remove trailing separator if present - if (components.length > 0 && components[components.length - 1]?.type === 14) { + if ( + components.length > 0 && + components[components.length - 1]?.type === 14 + ) { components.pop(); } if (components.length === 1) { - components.push({ type: 10, content: '*Sin estadísticas registradas.*' }); + components.push({ + type: 10, + content: "*Sin estadísticas registradas.*", + }); } // Crear DisplayComponent const display = { type: 17, - accent_color: 0x5865F2, - components + accent_color: 0x5865f2, + components, }; // Enviar con flags @@ -74,11 +97,13 @@ export const command: CommandMessage = { content: null, components: [display], flags: 32768, // MessageFlags.IS_COMPONENTS_V2 - reply: { messageReference: message.id } + reply: { messageReference: message.id }, }); } catch (error) { - console.error('Error en comando stats:', error); - await message.reply('❌ Error al obtener las estadísticas.'); + console.error("Error en comando stats:", error); + await message.reply( + "<:Cross:1420535096208920576> Error al obtener las estadísticas." + ); } - } + }, }; diff --git a/src/commands/messages/game/tienda.ts b/src/commands/messages/game/tienda.ts index 3a831ce..f8379db 100644 --- a/src/commands/messages/game/tienda.ts +++ b/src/commands/messages/game/tienda.ts @@ -178,7 +178,9 @@ export const command: CommandMessage = { console.error("Error handling shop interaction:", error); if (!interaction.replied && !interaction.deferred) { await interaction.reply({ - content: `❌ Error: ${error?.message ?? error}`, + content: `<:Cross:1420535096208920576> Error: ${ + error?.message ?? error + }`, flags: MessageFlags.Ephemeral, }); } @@ -229,7 +231,7 @@ async function buildShopPanel( }, { type: 14, - divider: true, + divider: false, spacing: 2, }, ], @@ -277,13 +279,13 @@ async function buildShopPanel( container.components.push({ type: 10, content: `${label}\n\n${ - item.description || undefined + item.description || null }${statsInfo}\n\nPrecio: ${price}${stockInfo}`, }); container.components.push({ type: 14, - divider: true, + divider: false, spacing: 1, }); } @@ -308,7 +310,7 @@ async function buildShopPanel( const stockText = offer.stock != null ? ` (${offer.stock} disponibles)` : ""; - const selectedMark = isSelected ? " ✓" : ""; + const selectedMark = isSelected ? " " : ""; container.components.push({ type: 9,