import {Modal} from "./Modal"; import { ActionRowBuilder, Interaction, MessageComponentInteraction, ModalSubmitInteraction, TextInputBuilder } from "discord.js"; import {EventHandler} from "../../Events/EventHandler"; export type RequestResponse = { interaction: ModalSubmitInteraction, value: string } export class Prompt extends Modal { constructor(eventHandler: EventHandler) { super(eventHandler); } public async requestValue( label: string, field: TextInputBuilder, interaction: MessageComponentInteraction ): Promise { const modal = this.getBuilder() .setTitle(label); field.setCustomId("value"); const actionRow = new ActionRowBuilder(); actionRow.setComponents([field]) modal.setComponents(actionRow); await interaction.showModal(modal); const responseInteraction = await this.awaitResponse(); const value = responseInteraction.fields.getTextInputValue("value"); return { value, interaction: responseInteraction }; } }