Form

Information of Form

What is Form

A modal that has toggles, slider, label, dropdown, input, and custom buttons

Example

import Form from './src/api/packets/Form.js'

const form = new Form()
.setId(69)
.setTitle('Form')
.addToggle('Toggle')
.addInput('Input', 'Enter something')
.addLabel('A label ')
.addDropdown('Dropdown', '1', '2')
.addSlider('Slider', 0, 10, 1)
.setButtons([
    { text: "Hello" },
    { text: "Hello 2" },
])

form.onResponse = (player, data) => {
    player.send(String(data))
}

form.execute(player)

API

interface Form {
    setId(id: number)
    setTitle(title: string)
    addToggle(title: string)
    .addInput(title: string, placeholder: string)
    .addLabel(label: string)
    .addDropdown(title: string, ...options: string)
    .addSlider(title: string, min: number, max: number, step: number)
    .setButtons(addButton[])
    
    abstract onResponse(player: Player, data: any[])
    
    execute(player: Player)
}

Last updated