feat: add admin commands for managing guild and global command, testing..
This commit is contained in:
33
src/components/buttons/cmdClearGlobal.ts
Normal file
33
src/components/buttons/cmdClearGlobal.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { ButtonInteraction } from 'discord.js';
|
||||
import { clearGlobalCommands } from '../../core/api/discordAPI';
|
||||
|
||||
const OWNER_ID = '327207082203938818';
|
||||
let running = false;
|
||||
|
||||
export default {
|
||||
customId: 'cmd_clear_global',
|
||||
run: async (interaction: ButtonInteraction) => {
|
||||
if (interaction.user.id !== OWNER_ID) {
|
||||
return interaction.reply({ content: '❌ No autorizado.', ephemeral: true });
|
||||
}
|
||||
if (running) {
|
||||
return interaction.reply({ content: '⏳ Limpieza GLOBAL en progreso, espera.', ephemeral: true });
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
await clearGlobalCommands();
|
||||
await interaction.editReply('🧹 Comandos GLOBAL eliminados.');
|
||||
} catch (e: any) {
|
||||
console.error('Error limpiando comandos globales:', e);
|
||||
if (interaction.deferred || interaction.replied) {
|
||||
await interaction.editReply('❌ Error limpiando comandos globales.');
|
||||
} else {
|
||||
await interaction.reply({ content: '❌ Error limpiando comandos globales.', ephemeral: true });
|
||||
}
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
33
src/components/buttons/cmdClearGuild.ts
Normal file
33
src/components/buttons/cmdClearGuild.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { ButtonInteraction } from 'discord.js';
|
||||
import { clearAllCommands } from '../../core/api/discordAPI';
|
||||
|
||||
const OWNER_ID = '327207082203938818';
|
||||
let running = false;
|
||||
|
||||
export default {
|
||||
customId: 'cmd_clear_guild',
|
||||
run: async (interaction: ButtonInteraction) => {
|
||||
if (interaction.user.id !== OWNER_ID) {
|
||||
return interaction.reply({ content: '❌ No autorizado.', ephemeral: true });
|
||||
}
|
||||
if (running) {
|
||||
return interaction.reply({ content: '⏳ Limpieza GUILD en progreso, espera.', ephemeral: true });
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
await clearAllCommands();
|
||||
await interaction.editReply('🧹 Comandos de GUILD eliminados.');
|
||||
} catch (e: any) {
|
||||
console.error('Error limpiando comandos guild:', e);
|
||||
if (interaction.deferred || interaction.replied) {
|
||||
await interaction.editReply('❌ Error limpiando comandos de guild.');
|
||||
} else {
|
||||
await interaction.reply({ content: '❌ Error limpiando comandos de guild.', ephemeral: true });
|
||||
}
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
33
src/components/buttons/cmdRegisterGlobal.ts
Normal file
33
src/components/buttons/cmdRegisterGlobal.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { ButtonInteraction } from 'discord.js';
|
||||
import { registeringGlobalCommands } from '../../core/api/discordAPI';
|
||||
|
||||
const OWNER_ID = '327207082203938818';
|
||||
let running = false;
|
||||
|
||||
export default {
|
||||
customId: 'cmd_reg_global',
|
||||
run: async (interaction: ButtonInteraction) => {
|
||||
if (interaction.user.id !== OWNER_ID) {
|
||||
return interaction.reply({ content: '❌ No autorizado.', ephemeral: true });
|
||||
}
|
||||
if (running) {
|
||||
return interaction.reply({ content: '⏳ Ya hay un registro GLOBAL en curso, espera.', ephemeral: true });
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
await registeringGlobalCommands();
|
||||
await interaction.editReply('✅ Comandos GLOBAL registrados (propagación puede tardar).');
|
||||
} catch (e: any) {
|
||||
console.error('Error registrando comandos globales:', e);
|
||||
if (interaction.deferred || interaction.replied) {
|
||||
await interaction.editReply('❌ Error registrando comandos globales.');
|
||||
} else {
|
||||
await interaction.reply({ content: '❌ Error registrando comandos globales.', ephemeral: true });
|
||||
}
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
33
src/components/buttons/cmdRegisterGuild.ts
Normal file
33
src/components/buttons/cmdRegisterGuild.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { ButtonInteraction } from 'discord.js';
|
||||
import { registeringCommands } from '../../core/api/discordAPI';
|
||||
|
||||
const OWNER_ID = '327207082203938818';
|
||||
let running = false;
|
||||
|
||||
export default {
|
||||
customId: 'cmd_reg_guild',
|
||||
run: async (interaction: ButtonInteraction) => {
|
||||
if (interaction.user.id !== OWNER_ID) {
|
||||
return interaction.reply({ content: '❌ No autorizado.', ephemeral: true });
|
||||
}
|
||||
if (running) {
|
||||
return interaction.reply({ content: '⏳ Ya hay un registro de comandos guild en curso, espera.', ephemeral: true });
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
await registeringCommands();
|
||||
await interaction.editReply('✅ Comandos de GUILD registrados correctamente.');
|
||||
} catch (e: any) {
|
||||
console.error('Error registrando comandos guild:', e);
|
||||
if (interaction.deferred || interaction.replied) {
|
||||
await interaction.editReply('❌ Error registrando comandos de guild. Revisa logs.');
|
||||
} else {
|
||||
await interaction.reply({ content: '❌ Error registrando comandos de guild.', ephemeral: true });
|
||||
}
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user