oopscord.js
    Preparing search index...

    Class BaseModal

    The base class for modals created with the Modal decorator. This class is used to create a modal from the options and components defined in the class, and to override the default options and component values with new options and values when creating the modal.

    import { ModalSubmitInteraction } from "discord.js";
    import { Modal, BaseModal, Interaction, Run } from "oopscord.js";

    Modal({
    customId: "my_modal",
    title: "My Modal"
    })
    ModalLabel({
    customId: "my_label",
    label: "This is a label",
    component: { type: "text_input", customId: "my_text_input", style: TextInputStyle.Short, placeholder: "Enter something...", required: true }
    })
    class MyModal extends BaseModal {
    constructor(@Interaction readonly interaction: ModalSubmitInteraction, @TextInputFieldInjection("my_text_input") readonly textInputValue: string) {
    super();
    }

    Run
    async run() {
    await this.interaction.reply(`You entered: ${this.textInputValue}`);
    }
    }
    Index

    Constructors

    Methods

    • Shows modal to user and recieve the input.

      Parameters

      • itr:
            | ChatInputCommandInteraction<CacheType>
            | MessageContextMenuCommandInteraction<CacheType>
            | UserContextMenuCommandInteraction<CacheType>
            | PrimaryEntryPointCommandInteraction<CacheType>
            | StringSelectMenuInteraction<CacheType>
            | UserSelectMenuInteraction<CacheType>
            | RoleSelectMenuInteraction<CacheType>
            | MentionableSelectMenuInteraction<CacheType>
            | ChannelSelectMenuInteraction<CacheType>
            | ButtonInteraction<CacheType>

        The interaction to show the modal to. Must be a command or button interaction.

      Returns Promise<ModalSubmitFields<CacheType>>

      The fields submitted by the user in the modal.

    • Returns a new ModalBuilder with the specified options and component values merged with the default options and components defined in the class.

      Parameters

      • options: Partial<ModalOptions> = {}

        The options to merge with the default options.

      • ...values: ModalValueOverride[]

        The component values to merge with the default components. The customId property is used to match the values with the correct components, and the type property is used to determine which type of component the value is for.

      Returns ModalBuilder