DiscordPHP-BridgeBot Documentation

Format
in package

FinalYes

Renders an answer for whichever chat asked the question.

The same action answers into a 2000-character Markdown-rendering Discord channel and a 500-character flat-text one somewhere else. Rather than every action carrying a if ($surface ...), they hand structured values to these helpers and let the surface decide.

Nothing here names a platform. What it asks the surface is what it actually needs to know — does markdown render, can a message contain a line break, how long may it be — so a connector for a network nobody has written yet gets sensible output without this file being touched.

Tags
author

Valithor Obsidion valithor@discordphp.org

Table of Contents

Methods

clamp()  : string
Clamps to the surface's limit, marking the truncation.
code()  : string
A block of preformatted text — fenced where markdown renders, inlined where it does not.
duration()  : string
Seconds as `3h 14m`, or `just now` under a minute.
fields()  : string
A set of labelled values: a fenced block where markdown renders, `a: b · c: d` where it does not.
listing()  : string
A list of items: numbered where markdown renders, comma-joined where it does not.
number()  : string
`1.2k`, `3.4M` — viewer and follower counts get large.
scalar()  : string

Methods

clamp()

Clamps to the surface's limit, marking the truncation.

public static clamp(string $text, Surface $surface) : string
Parameters
$text : string
$surface : Surface
Return values
string

code()

A block of preformatted text — fenced where markdown renders, inlined where it does not.

public static code(Surface $surface, string $text[, string $language = '' ]) : string
Parameters
$surface : Surface
$text : string
$language : string = ''
Return values
string

duration()

Seconds as `3h 14m`, or `just now` under a minute.

public static duration(int $seconds) : string
Parameters
$seconds : int
Return values
string

fields()

A set of labelled values: a fenced block where markdown renders, `a: b · c: d` where it does not.

public static fields(Surface $surface, array<string, string|int|float|bool|null> $fields[, string $title = '' ]) : string
Parameters
$surface : Surface
$fields : array<string, string|int|float|bool|null>
$title : string = ''
Return values
string

listing()

A list of items: numbered where markdown renders, comma-joined where it does not.

public static listing(Surface $surface, array<int, string> $items[, string $title = '' ][, string $empty = 'nothing to show' ]) : string
Parameters
$surface : Surface
$items : array<int, string>
$title : string = ''
$empty : string = 'nothing to show'
Return values
string

number()

`1.2k`, `3.4M` — viewer and follower counts get large.

public static number(int|float $value) : string
Parameters
$value : int|float
Return values
string

scalar()

private static scalar(mixed $value) : string
Parameters
$value : mixed
Return values
string
On this page

Search results