Modal

Information of modal

What is Modal?

It's a form that has 2 buttons (Y/N)

Example

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

const modal = new Modal()
.setId(69)
.setTitle('Player Modification')
.setContent('Enable fly command?')
.setButton1('Yes') // if player click this button, it will `true`
.setButton2('No')// if player click this button, it will `false`

modal.onResponse = (player, accepted) => {
    if(accepted)
        player.send('Modal: You accepted')
    else 
        player.send('Modal: You declined')
}

modal.execute(player)

API

interface Modal {
    setId(id: number)
    setTitle(title: string)    
    setContent(content: string)
    setButton1(btn: string)
    setButton2(btn: string)    
    
    abstract onResponse(player: Player, accepted: boolean)
    
    execute(player: Player)
}

Last updated