import {EventHandler} from "../../Events/EventHandler"; import {randomUUID} from "node:crypto"; import {ModalBuilder, ModalSubmitInteraction} from "discord.js"; import {ModalInteractionEvent} from "../../Events/ModalInteractionEvent"; export abstract class Modal { private readonly modalId: string; protected constructor( private readonly eventHandler: EventHandler ) { this.modalId = randomUUID(); } protected getBuilder(): ModalBuilder { return new ModalBuilder() .setCustomId(this.modalId); } protected awaitResponse(): Promise { return new Promise((resolve) => { this.eventHandler.addHandler(ModalInteractionEvent.name, (ev) => { if (this.modalId !== ev.interaction.customId) { return; } resolve(ev.interaction); }) }) } }