fix(racha): evitar type:9 sin accessory usando componentsV2 builder; corrige Invalid Form Body en display de racha
This commit is contained in:
@@ -3,6 +3,7 @@ import type Amayo from "../../../core/client";
|
|||||||
import { getStreakInfo, updateStreak } from "../../../game/streaks/service";
|
import { getStreakInfo, updateStreak } from "../../../game/streaks/service";
|
||||||
import type { TextBasedChannel } from "discord.js";
|
import type { TextBasedChannel } from "discord.js";
|
||||||
import { fetchItemBasics, formatItemLabel, sendDisplayReply } from "./_helpers";
|
import { fetchItemBasics, formatItemLabel, sendDisplayReply } from "./_helpers";
|
||||||
|
import { buildDisplay, textBlock, dividerBlock } from "../../../core/lib/componentsV2";
|
||||||
|
|
||||||
export const command: CommandMessage = {
|
export const command: CommandMessage = {
|
||||||
name: "racha",
|
name: "racha",
|
||||||
@@ -22,51 +23,33 @@ export const command: CommandMessage = {
|
|||||||
guildId
|
guildId
|
||||||
);
|
);
|
||||||
|
|
||||||
// Construir componentes
|
// Construir bloques de display (evitando type:9 sin accessory)
|
||||||
const components: any[] = [
|
const blocks: any[] = [
|
||||||
{
|
textBlock(`# 🔥 Racha Diaria de ${message.author.username}`),
|
||||||
type: 10,
|
dividerBlock(),
|
||||||
content: `# 🔥 Racha Diaria de ${message.author.username}`,
|
textBlock(
|
||||||
},
|
`**📊 ESTADÍSTICAS**\n` +
|
||||||
{ type: 14, divider: true },
|
`🔥 Racha Actual: **${streak.currentStreak}** días\n` +
|
||||||
{
|
`⭐ Mejor Racha: **${streak.longestStreak}** días\n` +
|
||||||
type: 9,
|
`📅 Días Activos: **${streak.totalDaysActive}** días`
|
||||||
components: [
|
),
|
||||||
{
|
dividerBlock({ spacing: 1 }),
|
||||||
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 },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Mensaje de estado
|
// Mensaje de estado
|
||||||
if (newDay) {
|
if (newDay) {
|
||||||
if (daysIncreased) {
|
if (daysIncreased) {
|
||||||
components.push({
|
blocks.push(
|
||||||
type: 9,
|
textBlock(
|
||||||
components: [
|
`**✅ ¡RACHA INCREMENTADA!**\nHas mantenido tu racha por **${streak.currentStreak}** días seguidos.`
|
||||||
{
|
)
|
||||||
type: 10,
|
);
|
||||||
content: `**✅ ¡RACHA INCREMENTADA!**\nHas mantenido tu racha por **${streak.currentStreak}** días seguidos.`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
components.push({
|
blocks.push(
|
||||||
type: 9,
|
textBlock(
|
||||||
components: [
|
`**⚠️ RACHA REINICIADA**\nPasó más de un día sin actividad. Tu racha se ha reiniciado.`
|
||||||
{
|
)
|
||||||
type: 10,
|
);
|
||||||
content: `**⚠️ RACHA REINICIADA**\nPasó más de un día sin actividad. Tu racha se ha reiniciado.`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mostrar recompensas
|
// Mostrar recompensas
|
||||||
@@ -90,27 +73,15 @@ export const command: CommandMessage = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
components.push({ type: 14, spacing: 1 });
|
blocks.push(dividerBlock({ spacing: 1 }));
|
||||||
components.push({
|
blocks.push(textBlock(rewardsText));
|
||||||
type: 9,
|
|
||||||
components: [
|
|
||||||
{
|
|
||||||
type: 10,
|
|
||||||
content: rewardsText,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
components.push({
|
blocks.push(
|
||||||
type: 9,
|
textBlock(
|
||||||
components: [
|
`**ℹ️ YA RECLAMASTE HOY**\nYa has reclamado tu recompensa diaria. Vuelve mañana para continuar tu racha.`
|
||||||
{
|
)
|
||||||
type: 10,
|
);
|
||||||
content: `**ℹ️ YA RECLAMASTE HOY**\nYa has reclamado tu recompensa diaria. Vuelve mañana para continuar tu racha.`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Próximos hitos
|
// Próximos hitos
|
||||||
@@ -119,23 +90,18 @@ export const command: CommandMessage = {
|
|||||||
|
|
||||||
if (nextMilestone) {
|
if (nextMilestone) {
|
||||||
const remaining = nextMilestone - streak.currentStreak;
|
const remaining = nextMilestone - streak.currentStreak;
|
||||||
components.push({ type: 14, spacing: 1 });
|
blocks.push(dividerBlock({ spacing: 1 }));
|
||||||
components.push({
|
blocks.push(
|
||||||
type: 9,
|
textBlock(
|
||||||
components: [
|
`**🎯 PRÓXIMO HITO**\nFaltan **${remaining}** días para alcanzar el día **${nextMilestone}**`
|
||||||
{
|
)
|
||||||
type: 10,
|
);
|
||||||
content: `**🎯 PRÓXIMO HITO**\nFaltan **${remaining}** días para alcanzar el día **${nextMilestone}**`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const display = {
|
const display = buildDisplay(
|
||||||
type: 17,
|
daysIncreased ? 0x00ff00 : 0xffa500,
|
||||||
accent_color: daysIncreased ? 0x00ff00 : 0xffa500,
|
blocks
|
||||||
components,
|
);
|
||||||
};
|
|
||||||
|
|
||||||
await sendDisplayReply(message, display);
|
await sendDisplayReply(message, display);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user