For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /server-ui/classes/MessageBox.md.

Class: MessageBox

Beta

A simple message form with two buttons and a text body. Use this class to show a basic dialog to a player and handle the player's button selection.

Constructors

Constructor

new MessageBox(player, title): MessageBox

Beta

Parameters

player

Player

The player to show this message box to.

title

string | ObservableString | ObservableUIRawMessage | UIRawMessage

The title text to display at the top of the message box.

Returns

MessageBox

Remarks

Creates a new MessageBox for the specified player with the given title.

Throws

This function can throw errors.

InvalidEntityError

Methods

body()

body(body): MessageBox

World Mutation Beta

Parameters

body

string | ObservableString | ObservableUIRawMessage | UIRawMessage

The body text to display. Accepts either a plain string or an ObservableString.

Returns

MessageBox

Remarks

Sets the body text displayed in the message box. Returns the message box instance to allow method chaining.

Throws

This function can throw errors.

InvalidFormModificationError


button1()

button1(label, tooltip?): MessageBox

World Mutation Beta

Parameters

label

string | ObservableString | ObservableUIRawMessage | UIRawMessage

The text label to display on the first button.

tooltip?

string | ObservableString | ObservableUIRawMessage | UIRawMessage

Optional tooltip text shown when hovering over the first button.

Returns

MessageBox

Remarks

Sets the label for the first button of the message box. Returns the message box instance to allow method chaining.

Throws

This function can throw errors.

InvalidFormModificationError


button1WithOptions()

button1WithOptions(label, options?): MessageBox

Beta World Mutation

Parameters

label

string | ObservableString | ObservableUIRawMessage | UIRawMessage

The text label to display on the first button.

options?

MessageBoxButtonOptions

Optional configuration for the first button, such as tooltip and image.

Returns

MessageBox

Remarks

Sets the label and options for the first button of the message box. Returns the message box instance to allow method chaining.

Throws

This function can throw errors.

InvalidFormModificationError


button2()

button2(label, tooltip?): MessageBox

World Mutation Beta

Parameters

label

string | ObservableString | ObservableUIRawMessage | UIRawMessage

The text label to display on the second button.

tooltip?

string | ObservableString | ObservableUIRawMessage | UIRawMessage

Optional tooltip text shown when hovering over the second button.

Returns

MessageBox

Remarks

Sets the label for the second button of the message box. Returns the message box instance to allow method chaining.

Throws

This function can throw errors.

InvalidFormModificationError


button2WithOptions()

button2WithOptions(label, options?): MessageBox

Beta World Mutation

Parameters

label

string | ObservableString | ObservableUIRawMessage | UIRawMessage

The text label to display on the second button.

options?

MessageBoxButtonOptions

Optional configuration for the second button, such as tooltip and image.

Returns

MessageBox

Remarks

Sets the label and options for the second button of the message box. Returns the message box instance to allow method chaining.

Throws

This function can throw errors.

InvalidFormModificationError


close()

close(): void

World Mutation Beta

Returns

void

Remarks

Closes the message box if it is currently being shown to the player. Throws a FormVisibilityError if the form is not currently open.

Throws

This function can throw errors.

EngineError

FormVisibilityError

InvalidEntityError


isShowing()

isShowing(): boolean

World Mutation Beta

Returns

boolean

Remarks

Returns true if the message box is currently being shown to the player, false otherwise.


show()

show(): Promise<MessageBoxResult>

World Mutation Beta

Returns

Promise<MessageBoxResult>

Remarks

Shows the message box to the player. Returns a promise that resolves with a MessageBoxResult containing the close reason and the player's button selection.

Throws

This function can throw errors.

EngineError

FormVisibilityError

InvalidEntityError