DiscordPHP-BridgeBot Documentation

DiscordMedia
in package

FinalYes

Recognises a link to a picture on Discord's own CDN.

Discord's GIF picker sends a favourited image as a bare link, and Discord shows that link as the picture itself. Relayed as text it is only a link everywhere else, so a message that is nothing but one of these is relayed as the picture instead.

Only Discord's CDN, because its URLs say what a file is without fetching it: the extension is the format. Its image endpoints — avatars, banners, icons, emojis — also render an animated image in whichever format is asked for, and an animated WebP is asked for as a GIF, the one animated format every network plays. Uploaded files are served as they are, so those are taken as given.

Tags
author

Valithor Obsidion valithor@discordphp.org

Table of Contents

Constants

HOSTS  : mixed = ['cdn.discordapp.com', 'media.discordapp.net']
TYPES  : mixed = ['gif' => 'image/gif', 'png' => 'image/png', 'j...
The image formats Discord serves, by extension.

Methods

fromUrl()  : Media|null
A picture on Discord's CDN, or `null` for anything else.

Constants

HOSTS

private mixed HOSTS = ['cdn.discordapp.com', 'media.discordapp.net']

TYPES

The image formats Discord serves, by extension.

private mixed TYPES = ['gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'webp' => 'image/webp']

Methods

fromUrl()

A picture on Discord's CDN, or `null` for anything else.

public static fromUrl(string $url) : Media|null
Parameters
$url : string
Return values
Media|null
On this page

Search results