Discord.https - v3.0.16
    Preparing search index...

    Class TextInputBuilder

    A builder that creates API-compatible JSON data for text inputs.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    • Creates a new text input from API data.

      Parameters

      Returns TextInputBuilder

      Creating a text input from an API data object:

      const textInput = new TextInputBuilder({
      custom_id: 'a cool text input',
      placeholder: 'Type something',
      style: TextInputStyle.Short,
      });

      Creating a text input using setters and API data:

      const textInput = new TextInputBuilder({
      placeholder: 'Type something else',
      })
      .setCustomId('woah')
      .setStyle(TextInputStyle.Paragraph);

    Properties

    data: Partial<DataType>

    The API data associated with this component.

    Methods

    • Clears the id of this component, defaulting to a default incremented id.

      Returns this

    • Sets the custom id for this text input.

      Parameters

      • customId: string

        The custom id to use

      Returns this

    • Sets the id (not the custom id) for this component.

      Parameters

      • id: number

        The id for this component

      Returns this

    • Sets the label for this text input.

      Parameters

      • label: string

        The label to use

      Returns this

      Use a label builder to create a label (and optionally a description) instead.

    • Sets the maximum length of text for this text input.

      Parameters

      • maxLength: number

        The maximum length of text for this text input

      Returns this

    • Sets the minimum length of text for this text input.

      Parameters

      • minLength: number

        The minimum length of text for this text input

      Returns this

    • Sets the placeholder for this text input.

      Parameters

      • placeholder: string

        The placeholder to use

      Returns this

    • Sets whether this text input is required.

      Parameters

      • Optionalrequired: boolean

        Whether this text input is required

      Returns this

    • Sets the style for this text input.

      Parameters

      Returns this

    • Sets the value for this text input.

      Parameters

      • value: string

        The value to use

      Returns this

    • Serializes this builder to API-compatible JSON data.

      Returns APITextInputComponent

      This method runs validations on the data before serializing it. As such, it may throw an error if the data is invalid.