mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
feat: implemented dist package.json
This commit is contained in:
1 parent
e34a6c6e4b
commit
4c2b0253de
7 files changed
+46
-29
No files matched your search
@@ -1,21 +1,31 @@
|
||||
import { ButtonInteraction, CacheType } from 'discord.js';
|
||||
import { CYCLIC_API } from '../../../constants/cyclic.js';
|
||||
import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable.js';
|
||||
import throwError from '../../../core/node/throwError.js';
|
||||
import { commands } from '../index.js';
|
||||
|
||||
export default async function handleButton(
|
||||
interaction: ButtonInteraction<CacheType>,
|
||||
) {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
const url = new URL(`${CYCLIC_API}/${interaction.customId}`);
|
||||
const commandName = url.pathname.split('/')[1];
|
||||
const button = commands[commandName]?.button;
|
||||
|
||||
if (!button) {
|
||||
console.error(`Button handler not found for "${commandName}"`);
|
||||
throwError(`Button handler not found for "${commandName}"`);
|
||||
return;
|
||||
}
|
||||
|
||||
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.deferUpdate();
|
||||
await interaction.message.edit(
|
||||
await normalizeInteractionReturnable(button(interaction)),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user