Modals

Video Tutorial

This video Tutorial goes over how to use modals in inventor.



Written Tutorial

This guide will walk you through creating a modal system in Discord with commands and flows. We’ll cover how to call a modal, handle its submission, and send data with modals. Follow along step-by-step to build your bot.


1. Calling the Modal

  1. Create the Flow
    • Name the flow My Modal.

    • Set the trigger to Slash Command.

    • Name the command modal and sync it.

  2. Add a Modal Reply to Interaction Block
    • Configure the block as follows:
      • Modal Name: Nickname

      • Custom ID: mymodal (remember this ID; it will be used later)

      • Field Label: Nickname

      • Required: True

      • Field Type: Large Field

Your calling flow is now complete. This flow triggers the modal.


2. Modal Submission Flow

  1. Create the Flow
    • Name the flow My Modal Submission.

    • Set the trigger to Modal Submit.

    • Use the Custom Modal ID from before: mymodal.

  2. Add an Embed Reply to Interaction Block
    • Configure the block as follows:
      • Description:
        • Write: Nickname:

        • Add the variable Modal Field 1 Value from the Modal Submit block.

Now, when the modal is submitted, the bot will respond with an embed containing the entered nickname.

  1. Test the Command
    • Run the /modal command in Discord.

    • The modal should appear with a field labeled Nickname.

  2. Submit the Modal
    • After submitting, the bot should respond with an embed containing:
      • Nickname: (value you entered)


3. Sending Data with Modals

This section explains how to pass data dynamically using the modal ID.

  1. Modify the Slash Command Flow
    • Add a Get Current Date and Time Block before the Modal Reply to Interaction Block.
      • Configure it to output the current time in HH:MM:SS format.

    • Edit the Modal Custom ID in the Modal Reply to Interaction block:
      • Set it to mymodal- and append the current time variable.

  2. Edit the Modal Submit Flow
    • Change the Modal Custom ID to mymodal-*.

    • Add a String Trim Prefix Block before the Embed Reply to Interaction block:

      • String: Use the Modal ID from the Modal Submit block.

      • Prefix: Set it to mymodal-.

    • Update the Embed Reply to Interaction Block:

      • Add the current time (from the String Trim Prefix block) to the Footer Text.


4. Testing the Modal

  1. Test the Command
    • Run the /modal command in Discord.

    • The modal should appear with a field labeled Nickname.

  2. Submit the Modal
    • After submitting, the bot should respond with an embed containing:
      • Nickname: (value you entered)

      • Footer: Showing the time.

  3. Test Multiple Times
    • Run the command twice, ensuring the seconds in the footer are different.


With this setup, you’ve created a dynamic modal system that includes timestamped data! This can be expanded further for advanced interactions.