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.

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.

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.

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.

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.

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.

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.

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.

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