DiscordPHP Documentation

ModalBuilder extends Builder
in package
implements JsonSerializable

Helper class used to build messages.

Tags
since
10.19.0
author

David Cole david.cole1340@gmail.com

Table of Contents

Interfaces

JsonSerializable

Properties

$components  : array<string|int, mixed>|array<string|int, ComponentObject>
Between 1 and 5 (inclusive) components that make up the modal contained in Action Row.
$custom_id  : string
Developer-defined identifier for the component, max 100 characters.
$title  : string
The title of the popup modal, max 45 characters.
$type  : int
Interaction type.

Methods

addComponent()  : $this
Add a component to the modal.
fromPart()  : self
Creates a new instance of the builder from a given Part.
getComponents()  : array<string|int, mixed>|array<string|int, ComponentObject>
Returns the components of the modal.
getCustomId()  : string
Returns the custom ID of the modal.
getTitle()  : string
Returns the title of the modal.
jsonSerialize()  : array<string|int, mixed>
new()  : static
Creates a new message builder.
removeComponent()  : $this
Removes a component from the builder.
setComponents()  : $this
Sets the components of the modal.
setCustomId()  : $this
Sets the custom ID of the modal.
setTitle()  : $this
Set the title of the modal.

Properties

$components

Between 1 and 5 (inclusive) components that make up the modal contained in Action Row.

protected array<string|int, mixed>|array<string|int, ComponentObject> $components

$custom_id

Developer-defined identifier for the component, max 100 characters.

protected string $custom_id

$title

The title of the popup modal, max 45 characters.

protected string $title

$type

Interaction type.

protected int $type = \Discord\Parts\Interactions\Interaction::RESPONSE_TYPE_MODAL

Methods

addComponent()

Add a component to the modal.

public addComponent(ComponentObject $component) : $this

Only ActionRow, TextInput, and Label components are allowed.

Using ActionRow in modals is now deprecated. Use Component::Label as the top level component.

Parameters
$component : ComponentObject
Return values
$this

fromPart()

Creates a new instance of the builder from a given Part.

public static fromPart(Part $part) : self
Parameters
$part : Part
Return values
self

getComponents()

Returns the components of the modal.

public getComponents() : array<string|int, mixed>|array<string|int, ComponentObject>
Return values
array<string|int, mixed>|array<string|int, ComponentObject>

getCustomId()

Returns the custom ID of the modal.

public getCustomId() : string
Return values
string

getTitle()

Returns the title of the modal.

public getTitle() : string
Return values
string

jsonSerialize()

public jsonSerialize() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

new()

Creates a new message builder.

public static new(mixed $title, mixed $custom_id, mixed $components) : static
Parameters
$title : mixed
$custom_id : mixed
$components : mixed
Return values
static

setComponents()

Sets the components of the modal.

public setComponents(array<string|int, mixed>|array<string|int, ComponentObject$components) : $this
Parameters
$components : array<string|int, mixed>|array<string|int, ComponentObject>
Return values
$this

setCustomId()

Sets the custom ID of the modal.

public setCustomId(string $custom_id) : $this
Parameters
$custom_id : string
Tags
throws
LengthException
Return values
$this

setTitle()

Set the title of the modal.

public setTitle(string $title) : $this
Parameters
$title : string

Maximum length is 45 characters.

Tags
throws
LengthException

Modal title too long.

Return values
$this

        
On this page

Search results