2025-09-23 23:06:15 -05:00
// Comando de administración para sincronizar / limpiar comandos (solo dueño)
// @ts-ignore
import { CommandMessage } from "../../../core/types/commands" ;
const OWNER_ID = '327207082203938818' ;
2025-09-23 23:37:50 -05:00
function formatBytesMB ( bytes : number ) {
return ( bytes / 1024 / 1024 ) . toFixed ( 1 ) + 'MB' ;
}
2025-09-23 23:06:15 -05:00
2025-09-23 23:37:50 -05:00
function buildAdminPanel() {
const m = process . memoryUsage ( ) ;
const rss = formatBytesMB ( m . rss ) ;
const heapUsed = formatBytesMB ( m . heapUsed ) ;
const heapTotal = formatBytesMB ( m . heapTotal ) ;
const ext = formatBytesMB ( m . external ) ;
const now = new Date ( ) ;
const ts = now . toISOString ( ) . replace ( 'T' , ' ' ) . split ( '.' ) [ 0 ] ;
return {
type : 17 ,
accent_color : 0x2b2d31 ,
components : [
{
type : 10 ,
content : '### 🛠️ Panel de Administración de Comandos\nGestiona el registro y limpieza de comandos **Slash**.'
} ,
{ type : 14 , divider : true , spacing : 1 } ,
{
type : 10 ,
content : 'Acciones disponibles:\n• Registrar comandos de GUILD (testing)\n• Registrar comandos GLOBAL (propagación lenta)\n• Limpiar comandos de GUILD\n• Limpiar comandos GLOBAL\n\nUsa los botones de abajo. Se evita ejecución simultánea.'
} ,
{ type : 14 , divider : true , spacing : 1 } ,
{
type : 10 ,
content : ` **Memoria (actual)** \ n• RSS: ${ rss } \ n• Heap Used: ${ heapUsed } \ n• Heap Total: ${ heapTotal } \ n• External: ${ ext } \ n \ nÚltima actualización: ${ ts } UTC `
} ,
{ type : 14 , divider : false , spacing : 1 } ,
// Fila 1 (acciones de registro)
2025-09-23 23:06:15 -05:00
{
type : 1 ,
components : [
{ type : 2 , style : 1 , label : 'Registrar GUILD' , custom_id : 'cmd_reg_guild' } ,
2025-09-23 23:37:50 -05:00
{ type : 2 , style : 1 , label : 'Registrar GLOBAL' , custom_id : 'cmd_reg_global' } ,
{ type : 2 , style : 2 , label : '🔄 Refrescar Memoria' , custom_id : 'cmd_mem_refresh' }
2025-09-23 23:06:15 -05:00
]
} ,
2025-09-23 23:37:50 -05:00
// Fila 2 (acciones de limpieza)
2025-09-23 23:06:15 -05:00
{
type : 1 ,
components : [
{ type : 2 , style : 4 , label : 'Limpiar GUILD' , custom_id : 'cmd_clear_guild' } ,
{ type : 2 , style : 4 , label : 'Limpiar GLOBAL' , custom_id : 'cmd_clear_global' }
]
}
2025-09-23 23:37:50 -05:00
]
} ;
}
export const command : CommandMessage = {
name : 'admin-comandos' ,
type : 'message' ,
aliases : [ 'cmdadmin' , 'synccommands' , 'comandos-admin' ] ,
cooldown : 5 ,
run : async ( message , _args , _client ) = > {
if ( message . author . id !== OWNER_ID ) {
await message . reply ( { content : '❌ No tienes permisos para usar este panel.' } ) ;
return ;
}
const panel = buildAdminPanel ( ) ;
2025-09-23 23:06:15 -05:00
await message . reply ( {
flags : 32768 ,
2025-09-23 23:37:50 -05:00
components : [ panel ]
2025-09-23 23:06:15 -05:00
} ) ;
}
} ;
2025-09-23 23:37:50 -05:00
// Exportamos builder para reutilizar en el botón de refresco
export { buildAdminPanel } ;