feat(events): Adds AcknowledgableEvent

This commit is contained in:
Michel Fedde 2025-06-22 15:51:14 +02:00
parent 6d7a0e7cfb
commit b82ab7dbc4
18 changed files with 228 additions and 77 deletions

View file

@ -1,7 +1,7 @@
import {EventHandler} from "../../Events/EventHandler";
import {randomUUID} from "node:crypto";
import {ModalBuilder, ModalSubmitInteraction} from "discord.js";
import {ModalInteractionEvent} from "../../Events/ModalInteractionEvent";
import {ModalInteractionEvent} from "../../Events/EventClasses/ModalInteractionEvent";
export abstract class Modal {
private readonly modalId: string;
@ -19,11 +19,14 @@ export abstract class Modal {
protected awaitResponse(): Promise<ModalSubmitInteraction>
{
return new Promise<ModalSubmitInteraction>((resolve) => {
this.eventHandler.addHandler<ModalInteractionEvent>(ModalInteractionEvent.name, (ev) => {
if (this.modalId !== ev.interaction.customId) {
return;
}
resolve(ev.interaction);
this.eventHandler.addHandler<ModalInteractionEvent>(ModalInteractionEvent.name, {
method: (ev) => {
if (this.modalId !== ev.interaction.customId) {
return;
}
resolve(ev.interaction);
},
persistent: false
})
})
}