Asset

discord_http.asset module

class discord_http.asset.Asset(*, url: str, key: str, animated: bool = False)[source]

Bases: object

BASE = 'https://cdn.discordapp.com'
async fetch() bytes[source]

Fetches the asset

Returns:

The asset data

Return type:

bytes

is_animated() bool[source]

Whether the asset is animated or not

Returns:

Whether the asset is animated or not

Return type:

bool

property key: str

The key of the asset

Returns:

The key of the asset

Return type:

str

async save(path: str) int[source]

Fetches the file from the attachment URL and saves it locally to the path

Parameters:

path (str) – Path to save the file to, which includes the filename and extension. Example: ./path/to/file.png

Returns:

The amount of bytes written to the file

Return type:

int

property url: str

The URL of the asset

Returns:

The URL of the asset

Return type:

str