From 9d2b2e6a9e856cfbe0687aeac2bbf657c2a01a7f Mon Sep 17 00:00:00 2001 From: Nix Krystik Date: Wed, 14 Oct 2026 11:41:51 +0800 Subject: [PATCH] (buttons): Implement `private-help` button. --- src/buttons/private-help.ts | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/buttons/private-help.ts b/src/buttons/private-help.ts index 82ef8fb..d1595e0 100644 --- a/src/buttons/private-help.ts +++ b/src/buttons/private-help.ts @@ -1,20 +1,30 @@ import { ButtonInteraction, Client, ModalBuilder, TextInputStyle, MessageFlags } from 'discord.js'; +import { Button } from '../types'; import { canOpenPrivateHelpTicket, createTextInput } from '../utils'; -export default { - name: 'private-help', - handler: async function (client: Client, interaction: ButtonInteraction) { - if (!(await canOpenPrivateHelpTicket(interaction.user.id))) - return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'You can only have one open ticket at a time that is less than a day old.' }); +class PrivateHelpButton implements Button { + id = 'private-help'; - const modal = new ModalBuilder() - .setCustomId('open-ticket-modal') - .setTitle('Get in contact'); + async execute(context: Client, interaction: ButtonInteraction, ...args: any[]): Promise { + try { + if (!await canOpenPrivateHelpTicket(interaction.user.id)) + throw new Error('You can only have one open ticket at a time that is less than a day old.'); - const label = createTextInput('ticket-message', 'What is the reason for your ticket?', null, true, TextInputStyle.Paragraph, 1500, 10); + const modal = new ModalBuilder() + .setCustomId('open-ticket-modal') + .setTitle('Get in contact'); - modal.addLabelComponents(label); + const label = createTextInput('ticket-message', 'What is the reason for your ticket?', null, true, TextInputStyle.Paragraph, 1500, 10); + modal.addLabelComponents(label); - await interaction.showModal(modal); + await interaction.showModal(modal); + } catch (error: Error | any) { + await interaction.reply({ + content: error.message, + flags: MessageFlags.Ephemeral, + }).catch(() => {}); + } } -}; \ No newline at end of file +} + +export default new PrivateHelpButton(); \ No newline at end of file