DiscordPHP-BridgeBot Documentation

Media

A connector whose network can carry a picture rather than a link to one, in both directions.

The distinction is not cosmetic. Twitch chat is text, so an attachment can only ever be relayed as a URL — and Discord's CDN links expire in about a day, so that link is dead by the time anyone reads the logs. Telegram can take the picture itself, and should, because then it is actually there.

The other direction matters as much. Some networks never hand out a URL a stranger may follow — a Telegram file link has the bot token in its path — so the only way a picture from there reaches Discord at all is for the connector to fetch the bytes and the relay to upload them.

Tags
author

Valithor Obsidion valithor@discordphp.org

Table of Contents

Methods

fetchMedia()  : PromiseInterface<string|int, array{filename: string, content: string}|null>
Fetches the bytes of something that arrived from this network, so the relay can upload it into Discord.
sendMedia()  : PromiseInterface<string|int, string|null>
Sends a picture or file into a room.

Methods

fetchMedia()

Fetches the bytes of something that arrived from this network, so the relay can upload it into Discord.

public fetchMedia(Media $media) : PromiseInterface<string|int, array{filename: string, content: string}|null>

Resolves to null for anything the connector will not copy — too large for Discord to accept, or not a file at all — and the relay names it instead. Never resolves to, rejects with, or logs a URL: on at least one network that URL is a credential.

Parameters
$media : Media
Return values
PromiseInterface<string|int, array{filename: string, content: string}|null>

sendMedia()

Sends a picture or file into a room.

public sendMedia(string $target, Media $media[, Outgoing|null $message = null ]) : PromiseInterface<string|int, string|null>

The whole Outgoing comes with it rather than a finished caption, because composing one is the connector's business: the caption limit is not the message limit on any network that has both, and the escaping is the connector's own.

Rejects when the network will not take it — too large, wrong type, a link it cannot reach — and the relay falls back to sending it as a link in the text, which every network can carry.

Parameters
$target : string
$media : Media
$message : Outgoing|null = null
Return values
PromiseInterface<string|int, string|null> —

The id of what was sent, when the network has them.

On this page

Search results