Container
extends Component
in package
implements
ComponentV2
Containers are a new way to group components together.
You can also specify an accent color (similar to embeds) and spoiler it.
Tags
Table of Contents
Interfaces
- ComponentV2
- This interface is a contract for V2 components.
Constants
- TYPE_ACTION_ROW = 1
- TYPE_BUTTON = 2
- TYPE_CHANNEL_SELECT = 8
- TYPE_CONTAINER = 17
- TYPE_CONTENT_INVENTORY_ENTRY = 16
- TYPE_FILE = 13
- TYPE_MEDIA_GALLERY = 12
- TYPE_MENTIONABLE_SELECT = 7
- TYPE_ROLE_SELECT = 6
- TYPE_SECTION = 9
- TYPE_SELECT_MENU = 3
- TYPE_SEPARATOR = 14
- TYPE_STRING_SELECT = 3
- TYPE_TEXT_DISPLAY = 10
- TYPE_TEXT_INPUT = 4
- TYPE_THUMBNAIL = 11
- TYPE_USER_SELECT = 5
Properties
- $accent_color : int|null
- Accent color for the container.
- $components : array<string|int, Component>
- Array of components.
- $spoiler : bool
- Whether the container is a spoiler.
Methods
- addComponent() : $this
- Adds a component to the container.
- addComponents() : $this
- Add a group of components to the container.
- getAccentColor() : int|null
- Returns the accent color for the container.
- getComponents() : array<string|int, Component>
- Returns all the components in the container.
- isSpoiler() : bool
- Returns whether the container is a spoiler.
- jsonSerialize() : array<string|int, mixed>
- {@inheritDoc}
- new() : self
- Creates a new container.
- setAccentColor() : $this
- Sets the accent color for the container.
- setComponents() : $this
- Sets the components for the container.
- setSpoiler() : $this
- Sets whether the container is a spoiler.
- generateUuid() : string
- Generates a UUID which can be used for component custom IDs.
Constants
TYPE_ACTION_ROW
public
mixed
TYPE_ACTION_ROW
= 1
TYPE_BUTTON
public
mixed
TYPE_BUTTON
= 2
TYPE_CHANNEL_SELECT
public
mixed
TYPE_CHANNEL_SELECT
= 8
TYPE_CONTAINER
public
mixed
TYPE_CONTAINER
= 17
TYPE_CONTENT_INVENTORY_ENTRY
public
mixed
TYPE_CONTENT_INVENTORY_ENTRY
= 16
TYPE_FILE
public
mixed
TYPE_FILE
= 13
TYPE_MEDIA_GALLERY
public
mixed
TYPE_MEDIA_GALLERY
= 12
TYPE_MENTIONABLE_SELECT
public
mixed
TYPE_MENTIONABLE_SELECT
= 7
TYPE_ROLE_SELECT
public
mixed
TYPE_ROLE_SELECT
= 6
TYPE_SECTION
public
mixed
TYPE_SECTION
= 9
TYPE_SELECT_MENU
Use Component::TYPE_STRING_SELECT
public
mixed
TYPE_SELECT_MENU
= 3
TYPE_SEPARATOR
public
mixed
TYPE_SEPARATOR
= 14
TYPE_STRING_SELECT
public
mixed
TYPE_STRING_SELECT
= 3
TYPE_TEXT_DISPLAY
public
mixed
TYPE_TEXT_DISPLAY
= 10
TYPE_TEXT_INPUT
public
mixed
TYPE_TEXT_INPUT
= 4
TYPE_THUMBNAIL
public
mixed
TYPE_THUMBNAIL
= 11
TYPE_USER_SELECT
public
mixed
TYPE_USER_SELECT
= 5
Properties
$accent_color
Accent color for the container.
private
int|null
$accent_color
$components
Array of components.
private
array<string|int, Component>
$components
= []
$spoiler
Whether the container is a spoiler.
private
bool
$spoiler
= false
Methods
addComponent()
Adds a component to the container.
public
addComponent(ActionRow|Section|TextDisplay|MediaGallery|File|Separator $component) : $this
Parameters
- $component : ActionRow|Section|TextDisplay|MediaGallery|File|Separator
-
Component to add.
Tags
Return values
$thisaddComponents()
Add a group of components to the container.
public
addComponents(array<string|int, Component> $components) : $this
Parameters
- $components : array<string|int, Component>
-
Components to add.
Tags
Return values
$thisgetAccentColor()
Returns the accent color for the container.
public
getAccentColor() : int|null
Return values
int|nullgetComponents()
Returns all the components in the container.
public
getComponents() : array<string|int, Component>
Return values
array<string|int, Component>isSpoiler()
Returns whether the container is a spoiler.
public
isSpoiler() : bool
Return values
booljsonSerialize()
{@inheritDoc}
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>new()
Creates a new container.
public
static new() : self
Return values
selfsetAccentColor()
Sets the accent color for the container.
public
setAccentColor(int|null $color) : $this
Parameters
- $color : int|null
-
Color code for the container.
Return values
$thissetComponents()
Sets the components for the container.
public
setComponents(array<string|int, Component> $components) : $this
Parameters
- $components : array<string|int, Component>
-
Components to set.
Return values
$thissetSpoiler()
Sets whether the container is a spoiler.
public
setSpoiler([bool $spoiler = true ]) : $this
Parameters
- $spoiler : bool = true
-
Whether the container is a spoiler.
Return values
$thisgenerateUuid()
Generates a UUID which can be used for component custom IDs.
protected
static generateUuid() : string