Returns data about the player results from a modal action form.

import { Player } from '@minecraft/server';
import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui';

function askFavoriteMonth(player: Player) {
const form = new ActionFormData()
.title('Months')
.body('Choose your favorite month!')
.button('January')
.button('February')
.button('March')
.button('April')
.button('May');

form.show(player).then((response: ActionFormResponse) => {
if (response.selection === 3) {
player.sendMessage('I like April too!');
} else {
player.sendMessage('Nah, April is the best.');
}
});
}

Hierarchy (View Summary)

Properties

cancelationReason?: FormCancelationReason

Contains additional details as to why a form was canceled.

canceled: boolean

If true, the form was canceled by the player (e.g., they selected the pop-up X close button).

selection?: number

Returns the index of the button that was pushed.