InputBuilder class

const input = new InputBuilder(data?: object);

constructor

The constructor provides one optional argument which is an object which provides the data for the ButtonBuilder class.

The object may contain the following information:

  • custom_id: An id so you can recognize the input when the form has been submitted by a member. The id must be unique and a string between 1-100 characters.

  • min_length: A number which defines the minimum amount of characters a member should provide.

  • max_length: A number which defines the maximum amount of characters a member may provide.

  • value: A string which defines the default value of the input.

  • placeholder: A string which defines the default placeholder a member will see when no text has been written in the input.

  • required: A boolean which defines whether the input is required to fill in or not.

  • label: A string of maximum 45 characters which will be shown just above the input.

  • style: A number or a string which defines the type of style of the input. (short or paragraph)

Properties

custom_id

An id so you can recognize the input when the form has been submitted by a member. The id must be unique and a string between 1-100 characters.

min_length

A number which defines the minimum amount of characters a member should provide.

max_length

A number which defines the maximum amount of characters a member may provide.

value

A string which defines the default value of the input.

placeholder

A string which defines the default placeholder a member will see when no text has been written in the input.

required

A boolean which defines whether the input is required to fill in or not.

label

A string of maximum 45 characters which will be shown just above the input.

style

A number which defines the type of style of the input.

Functions

setCustomId

input.setCustomId(customId: string) : InputBuiilder;

Sets a custom id for the input which will be returned to the bot once the form the input has been added in has been submitted and makes you able to recognize the input. The function returns the same InputBuilder class so you don't have to declare it everytime again.

ArgumentDescription

customId

A string of max 100 characters which will be returned to the bot in the formSubmit event so you can recognize the iinput which was filled in by the member.

setRequired

input.setRequired(required?: boolean) : InputBuilder;

Defines whether the input must be filled in or not. The function returns the same InputBuilder class so you don't have to declare it everytime again.

ArgumentDescription

disabled

A boolean which defines whether the input must be filled in or not.

setLabel

input.setLabel(label: string) : InputBuilder;

Sets a label for the input which is visible just above the input for the member filling in the form. The function returns the same InputBuilder class so you don't have to declare it everytime again.

ArgumentDescription

label

A string of max 45 characters which will be visible just above the input in the form.

setValue

input.setValue(value: string) : InputBuilder;

Sets a default value for the input. The value will already be filled in when the member gets to see the form for the first time. The function returns the same InputBuilder class so you don't have to declare it everytime again.

ArgumentDescription

value

A string of max 100 characters which should be the default value of the input.

setStyle

input.setStyle(style: string | number) : InputBuilder;

Sets the style of the input and defines how the input will look like. The function returns the same InputBuilder class so you don't have to declare it everytime again.

ArgumentDescription

style

A string or a number which defines the style of the input. In the table below is explained which strings and numbers are allowed.

TypeDescription

Short or 1

The style of the input will become a short input of one line.

Paragraph or 2

The style of the input will become a longer input with multiple paragraphs.

setPlaceholder

input.setPlaceholder(placeholder: string) : InputBuilder;

Sets a placeholder for the input. This text will be visible when the input is empty. The function will return the same InputBuilder class so you don't have to declare it everytime again.

ArgumentDescription

placeholder

The placeholder you'd like to give the input. The placeholder will be visible when the member hasn't written anything in the input. This must be a string of maximum 100 characters.

setMinLength

input.setMinLength(minLength: number) : InputBuilder;

Sets the minimum length of characters which the member must provide. The function will return the same InputBuilder class so you don't have to declare it everytime again.

ArgumentDescription

minLength

The minimum amount of characters the member must provide in the input.

setMaxLength

input.setMaxLength(maxLength: number) : InputBuilder;

Sets the maximum length of characters which the member may provide. The function will return the same InputBuilder class so you don't have to declare it everytime again.

ArgumentDescription

maxLength

The minimum amount of characters the member may provide in the input.

toJSON

Converts the ButtonBuilder class to an object to make it a valid object for the Discord API. The function returns the same data as the data property.

{
    custom_id: string;
    style: number;
    label: string | null;
    placeholder: string | null;
    value: string | null;
    required: boolean;
    min_length: number | null;
    max_length: number | null;
}

Last updated