ModalBuilder
extends Builder
in package
implements
JsonSerializable
Helper class used to build messages.
Tags
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
$thisfromPart()
Creates a new instance of the builder from a given Part.
public
static fromPart(Part $part) : self
Parameters
- $part : Part
Return values
selfgetComponents()
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
stringgetTitle()
Returns the title of the modal.
public
getTitle() : string
Return values
stringjsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Tags
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
staticremoveComponent()
Removes a component from the builder.
public
removeComponent(ComponentObject $component) : $this
Parameters
- $component : ComponentObject
-
Component to remove.
Return values
$thissetComponents()
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
$thissetCustomId()
Sets the custom ID of the modal.
public
setCustomId(string $custom_id) : $this
Parameters
- $custom_id : string
Tags
Return values
$thissetTitle()
Set the title of the modal.
public
setTitle(string $title) : $this
Parameters
- $title : string
-
Maximum length is 45 characters.