feat: refactor success message handling in cache clear function to use plain objects
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import logger from "../../core/lib/logger";
|
import logger from "../../core/lib/logger";
|
||||||
import { ButtonInteraction, MessageFlags, ContainerBuilder, TextDisplayBuilder, SectionBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
|
import { ButtonInteraction, MessageFlags } from 'discord.js';
|
||||||
|
import { ComponentType, ButtonStyle } from 'discord-api-types/v10';
|
||||||
import { aiService } from '../../core/services/AIService';
|
import { aiService } from '../../core/services/AIService';
|
||||||
|
|
||||||
const OWNER_ID = '327207082203938818'; // Solo el dueño puede usar este panel
|
const OWNER_ID = '327207082203938818'; // Solo el dueño puede usar este panel
|
||||||
@@ -25,30 +26,37 @@ export default {
|
|||||||
// Aquí iría la lógica real de limpieza:
|
// Aquí iría la lógica real de limpieza:
|
||||||
// aiService.clearAllConversations();
|
// aiService.clearAllConversations();
|
||||||
|
|
||||||
// Crear container de éxito usando la API real
|
// Crear panel de éxito usando objetos planos
|
||||||
const successContainer = new ContainerBuilder()
|
const successPanel = {
|
||||||
.addTextDisplayComponents(
|
type: ComponentType.Container,
|
||||||
new TextDisplayBuilder()
|
components: [
|
||||||
.setContent('## 🧹 Cache Limpiado Exitosamente\n-# Se han limpiado ' + conversationsCleared + ' conversaciones activas.\n\n✅ **Estado:** Cache limpiado\n🔄 **Conversaciones eliminadas:** ' + conversationsCleared + '\n⏰ **Timestamp:** ' + new Date().toISOString().replace('T', ' ').split('.')[0] + ' UTC\n👤 **Dueño:** ' + interaction.user.username)
|
{
|
||||||
)
|
type: ComponentType.TextDisplay,
|
||||||
.addSectionComponents(
|
content: '## 🧹 Cache Limpiado Exitosamente\n-# Se han limpiado ' + conversationsCleared + ' conversaciones activas.\n\n✅ **Estado:** Cache limpiado\n🔄 **Conversaciones eliminadas:** ' + conversationsCleared + '\n⏰ **Timestamp:** ' + new Date().toISOString().replace('T', ' ').split('.')[0] + ' UTC\n👤 **Dueño:** ' + interaction.user.username
|
||||||
new SectionBuilder()
|
},
|
||||||
.addTextDisplayComponents(
|
{
|
||||||
new TextDisplayBuilder()
|
type: ComponentType.Section,
|
||||||
.setContent("🔙 Volver al panel principal de administración")
|
components: [
|
||||||
)
|
{
|
||||||
.setButtonAccessory(
|
type: ComponentType.TextDisplay,
|
||||||
new ButtonBuilder()
|
content: "🔙 Volver al panel principal de administración"
|
||||||
.setCustomId('ai_refresh_stats')
|
}
|
||||||
.setLabel('Volver al Panel')
|
],
|
||||||
.setEmoji('🔙')
|
accessory: {
|
||||||
.setStyle(ButtonStyle.Primary)
|
type: ComponentType.Button,
|
||||||
)
|
custom_id: 'ai_refresh_stats',
|
||||||
);
|
label: 'Volver al Panel',
|
||||||
|
emoji: { name: '🔙' },
|
||||||
|
style: ButtonStyle.Primary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
await interaction.message.edit({
|
await interaction.message.edit({
|
||||||
components: [successContainer],
|
// @ts-ignore - Flag de componentes V2
|
||||||
flags: MessageFlags.IsComponentsV2
|
flags: 32768,
|
||||||
|
components: [successPanel]
|
||||||
});
|
});
|
||||||
logger.info(`Cache de IA limpiado por el dueño ${interaction.user.username} (${interaction.user.id})`);
|
logger.info(`Cache de IA limpiado por el dueño ${interaction.user.username} (${interaction.user.id})`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user