DiscordPHP-BridgeBot Documentation

PanelBuilder extends MessageBuilder
in package

A {@see MessageBuilder} that is a Components v2 panel: one accented {@see Container} that everything else is added to.

It extends MessageBuilder rather than wrapping it so a panel is a message builder — anything that takes one (respondWithMessage(), updateMessage(), sendMessage(), Webhook::execute()) takes a panel, with no unwrapping step and nothing to keep in sync as DiscordPHP's builder grows. The named constructors follow the same shape as Button::primary(): a static per variant, then fluent methods.

Components v2 rather than embeds because these panels are not decorated text: a bridge list needs a button per row to unlink that row, which is exactly what a Section accessory is for and which an embed cannot express at all. Adding a v2 component sets the IS_COMPONENTS_V2 flag, which forbids content on the same message — so everything a panel says lives in a TextDisplay.

Every panel also sets allowed_mentions: none. Panels quote text supplied by another network — a room title, somebody's name — and none of it should be able to ping a Discord server.

Tags
since
1.0.0
author

Valithor Obsidion valithor@discordphp.org

Table of Contents

Constants

ACCENT  : mixed = 0x2aabee
A calm blue, for ordinary panels.
DANGER  : mixed = 0xed4245
MAX_ROWS  : mixed = 10
Discord allows 40 components in one v2 message, and each row costs a Section plus its text and its button. Ten rows leaves ample room for the heading, the separator and the footer.
SUCCESS  : mixed = 0x57f287
WARNING  : mixed = 0xfee75c

Properties

$container  : Container
The container every other component is added to.

Methods

addActions()  : static
Adds a row of buttons.
addRow()  : static
Adds a line of text with a button or thumbnail beside it — the only two things a Section accepts as an accessory.
addSeparator()  : static
Adds a divider.
addText()  : static
Adds a block of markdown.
confirm()  : static
A destructive action behind a second press.
error()  : static
getContainer()  : Container
The container, for anything these helpers do not cover.
links()  : static
This server's bridges, one row per link, each with its own Unlink button — the reason these panels are v2 and not embeds.
new()  : static
Creates an empty panel.
notice()  : static
A panel that is one block of markdown.
room()  : static
The panel for one room on another network: what the bot can see about it, and the things it can do to it from here.
setAccentColor()  : static
Recolours the container after the fact.
success()  : static
warning()  : static

Constants

ACCENT

A calm blue, for ordinary panels.

public mixed ACCENT = 0x2aabee

MAX_ROWS

Discord allows 40 components in one v2 message, and each row costs a Section plus its text and its button. Ten rows leaves ample room for the heading, the separator and the footer.

public mixed MAX_ROWS = 10

Properties

$container

The container every other component is added to.

protected Container $container

Methods

addActions()

Adds a row of buttons.

public addActions(Button ...$buttons) : static
Parameters
$buttons : Button
Return values
static

addRow()

Adds a line of text with a button or thumbnail beside it — the only two things a Section accepts as an accessory.

public addRow(string $markdown, Button|Thumbnail $accessory) : static
Parameters
$markdown : string
$accessory : Button|Thumbnail
Return values
static

addSeparator()

Adds a divider.

public addSeparator([bool $divider = true ]) : static
Parameters
$divider : bool = true
Return values
static

addText()

Adds a block of markdown.

public addText(string $markdown) : static
Parameters
$markdown : string
Return values
static

confirm()

A destructive action behind a second press.

public static confirm(string $markdown, string $confirmCustomId[, string $confirmLabel = 'Yes, do it' ]) : static

reset drops every bridge in the server, which is exactly the kind of thing somebody fires while meaning list.

Parameters
$markdown : string
$confirmCustomId : string
$confirmLabel : string = 'Yes, do it'
Return values
static

error()

public static error(string $markdown) : static
Parameters
$markdown : string
Return values
static

getContainer()

The container, for anything these helpers do not cover.

public getContainer() : Container
Return values
Container

This server's bridges, one row per link, each with its own Unlink button — the reason these panels are v2 and not embeds.

public static links(array<int, array{channel_id: string, target: string, title: ?string}> $rows[, string $connector = 'bridge' ]) : static
Parameters
$rows : array<int, array{channel_id: string, target: string, title: ?string}>
$connector : string = 'bridge'

Named in the empty state, so the instruction it gives is one the reader can actually type.

Return values
static

new()

Creates an empty panel.

public static new([int $accent = self::ACCENT ]) : static
Parameters
$accent : int = self::ACCENT

Container accent colour; one of the constants above.

Return values
static

notice()

A panel that is one block of markdown.

public static notice(string $markdown[, int $accent = self::ACCENT ]) : static
Parameters
$markdown : string
$accent : int = self::ACCENT
Return values
static

room()

The panel for one room on another network: what the bot can see about it, and the things it can do to it from here.

public static room(Room $room[, array<int, string> $linkedChannels = [] ]) : static

There is deliberately no thumbnail. On at least one network a room's photo is reachable only through a URL containing the bot token, and a panel is not the place to find that out — so the builder does not offer the option at all.

Parameters
$room : Room
$linkedChannels : array<int, string> = []

Discord channels bridged to it, for the footer.

Return values
static

setAccentColor()

Recolours the container after the fact.

public setAccentColor(int $accent) : static
Parameters
$accent : int
Return values
static

success()

public static success(string $markdown) : static
Parameters
$markdown : string
Return values
static

warning()

public static warning(string $markdown) : static
Parameters
$markdown : string
Return values
static
On this page

Search results