mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-14 05:06:11 +01:00
feat: migration 3
This commit is contained in:
1 parent
6285f33989
commit
4055988478
110 files changed
+28
-76
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { ButtonInteraction, CacheType } from 'discord.js';
|
||||
import { commands } from '..';
|
||||
import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable';
|
||||
|
||||
export default async function handleButton(
|
||||
interaction: ButtonInteraction<CacheType>,
|
||||
) {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
const url = new URL(`https://example.com/${interaction.customId}`);
|
||||
const commandName = url.pathname.split('/')[1];
|
||||
const button = (await commands)[commandName]?.button;
|
||||
|
||||
if (!button) {
|
||||
throw new Error(`Button handler not found for "${commandName}"`);
|
||||
}
|
||||
|
||||
if (interaction.message.interaction?.user.id !== interaction.user.id) {
|
||||
interaction.followUp({
|
||||
ephemeral: true,
|
||||
content: 'You are not the author of this command.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await interaction.message.edit(
|
||||
await normalizeInteractionReturnable(button(interaction)),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user