DiscordPHP-BridgeBot Documentation

Panels
in package
implements Module

FinalYes

The buttons on a `/telegram chat info` panel.

A module rather than actions, because these are not commands: they arrive as component interactions with no name attached, only a custom_id. An Action is a string in and a string out, which covers what a chat command is and nothing else.

Each button carries the chat id it was rendered for, so a panel still works after the channel it was posted in has been re-linked somewhere else — it refreshes what it was showing rather than whatever that channel points at now. That is also what makes it survive a restart: nothing is remembered between the panel and the press except what is written on the button.

What the button says is not the whole check, though. A panel outlives the bridge it was drawn for, and a server that has since unlinked a chat must not keep minting its invite links from an old message — so every press is held to a chat the pressing server bridges now.

Tags
author

Valithor Obsidion valithor@valgorithms.com

Table of Contents

Interfaces

Module
A self-contained Discord-side feature that attaches its own listeners once the gateway is ready.

Methods

boot()  : void
Attach listeners, timers, and slash-command handlers. Called once, after ready.
name()  : string
Stable short name, used for logging.
explain()  : PanelBuilder
Turns a Telegram failure into something worth reading.
invite()  : PromiseInterface
Mints an invite link — and says what that cost.
members()  : PromiseInterface
refresh()  : PromiseInterface
Redraws the panel in place, so it does not pile up copies in the channel.
withChat()  : PromiseInterface
Resolves which chat a button is about, and refuses politely when there is not one.

Methods

boot()

Attach listeners, timers, and slash-command handlers. Called once, after ready.

public boot(Bot $bot) : void
Parameters
$bot : Bot

name()

Stable short name, used for logging.

public name() : string
Return values
string

explain()

Turns a Telegram failure into something worth reading.

private explain(Throwable $e) : PanelBuilder

Never re-uses the exception's own message unexamined: a Telegram error can quote the request URL, and a Telegram URL carries the bot token.

Parameters
$e : Throwable
Return values
PanelBuilder

invite()

Mints an invite link — and says what that cost.

private invite(Bot $bot, Interaction $interaction, string|null $chatId) : PromiseInterface

Ephemeral, always, and gated: exportChatInviteLink revokes the previous link and creates a new one, so the answer is both a working invite to a private group and the reason the last one stopped working. It is not something to leave sitting in a channel.

Parameters
$bot : Bot
$interaction : Interaction
$chatId : string|null
Return values
PromiseInterface

members()

private members(Bot $bot, Interaction $interaction, string|null $chatId) : PromiseInterface
Parameters
$bot : Bot
$interaction : Interaction
$chatId : string|null
Return values
PromiseInterface

refresh()

Redraws the panel in place, so it does not pile up copies in the channel.

private refresh(Bot $bot, Interaction $interaction, string|null $chatId) : PromiseInterface
Parameters
$bot : Bot
$interaction : Interaction
$chatId : string|null
Return values
PromiseInterface

withChat()

Resolves which chat a button is about, and refuses politely when there is not one.

private withChat(Bot $bot, Interaction $interaction, string|null $chatId, callable(TelegramConnector, string): PromiseInterface $then) : PromiseInterface

The id on the button wins over the channel's current bridge; see the class docblock for why.

Parameters
$bot : Bot
$interaction : Interaction
$chatId : string|null
$then : callable(TelegramConnector, string): PromiseInterface
Return values
PromiseInterface
On this page

Search results