feat: refresh button

This commit is contained in:
TresAbhi committed 2023-06-25 02:32:56 +00:00
1 parent ae2d12a629
commit 58f5b894f9
30 files changed
+479 -299

No files matched your search

@@ -0,0 +1,20 @@
import { ButtonInteraction, CacheType } from 'discord.js';
import normalizeInteractionReturnable from '../../../core/interaction/normalizeInteractionReturnable.js';
import { commands } from '../index.js';
export default async function handleButton(
interaction: ButtonInteraction<CacheType>,
) {
const commandName = interaction.customId.split('/')[0];
const button = commands[commandName]?.button;
if (!button) {
console.error(`Button handler not found for "${commandName}"`);
return;
}
await interaction.deferUpdate();
await interaction.message.edit(
await normalizeInteractionReturnable(button(interaction)),
);
}