FormBuilder class

const formBuilder = new FormBuilder(options?: object);

constructor

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

The object may contain the following information:

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

  • title: The title the form should have.

  • inputs: An array with objects which defines the inputs which should be added in the form.

  • components: Identical to the inputs key.

Properties

title

A string which defines the title which was set for the form.

inputs

An array with objects which define the inputs which will be added in the form.

custom_id

A unique id where you can recognize the form with.

components

Identical to the inputs property.

Functions

setCustomId

formBuilder.setCustomId(customId: string) : FormBuilder;

Sets a custom id for the form which will be returned to the bot once the form has been submitted and makes you able to recognize the form. The function returns the same FormBuilder 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 button which was pressed by the member.

setTitle

formBuilder.setTitle(title: string) : FormBuilder;

Sets a title for the form which is visible to member who should fill the form in. The function returns the same FormBuilder class so you don't have to declare it everytime again.

ArgumentDescription

title

A string of max 45 characters which should be the title of the form.

addComponents

formBuilder.addComponents(...components: [InputBuilder]) : FormBuilder;

Adds inputs to the form which can be filled in by a member of a server. The function returns the same FormBuilder class so you don't have to declare it everytime again.

ArgumentDescription

components

(Multiple) arguments which are instances of the InputBuilder class and define the inputs a member can fill in.

addInputs

formBuilder.addInputs(...components: [InputBuilder]) : FormBuilder;

Identical to the addComponents function. Adds inputs to the form which can be filled in by a member of a server. The function returns the same FormBuilder class so you don't have to declare it everytime again.

ArgumentDescription

components

(Multiple) arguments which are instances of the InputBuilder class and define the inputs a member can fill in.

toJSON

Converts the FormBuilder 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;
    title?: string;
    inputs: [object];
}

Last updated