feat: improve component and command loading functions with directory existence checks
This commit is contained in:
23
src/components/buttons/ldRefresh.ts
Normal file
23
src/components/buttons/ldRefresh.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ButtonInteraction, MessageFlags } from 'discord.js';
|
||||
import { buildLeaderboardPanel } from '../../commands/messages/alliaces/leaderboard';
|
||||
|
||||
export default {
|
||||
customId: 'ld_refresh',
|
||||
run: async (interaction: ButtonInteraction) => {
|
||||
if (!interaction.guild) {
|
||||
return interaction.reply({ content: '❌ Solo disponible en servidores.', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
try {
|
||||
await interaction.deferUpdate();
|
||||
// Reusar el builder esperando un objeto con guild y author
|
||||
const fakeMessage: any = { guild: interaction.guild, author: interaction.user };
|
||||
const panel = await buildLeaderboardPanel(fakeMessage);
|
||||
await interaction.message.edit({ components: [panel] });
|
||||
} catch (e) {
|
||||
console.error('Error refrescando leaderboard:', e);
|
||||
if (!interaction.deferred && !interaction.replied)
|
||||
await interaction.reply({ content: '❌ Error refrescando leaderboard.', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user