Asset

discord_http.asset module

class discord_http.asset.Asset(*, state, url, key, animated=False)

Bases: object

Parameters:
BASE = 'https://cdn.discordapp.com'
PROXY = 'https://media.discordapp.net'
async fetch() bytes

Fetches the asset.

Return type:

bytes

Returns:

The asset data

is_animated() bool

Whether the asset is animated or not.

Return type:

bool

Returns:

Whether the asset is animated or not

property key: str

The key of the asset.

Return type:

The key of the asset

replace(*, size=<MISSING>, format=<MISSING>) Self

Replace the asset with new values.

Parameters:
  • size (int) – The size of the asset

  • format (AssetFormatTypes) – The format of the asset

Return type:

Self

Returns:

The new asset object

async save(path) int

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

Return type:

int

Returns:

The amount of bytes written to the file

property url: str

The URL of the asset.

Return type:

The URL of the asset

with_static_format(format) Self

Replace the asset with a static format.

Parameters:

format (StaticFormatTypes) – The static format to use

Return type:

Self

Returns:

The new asset object, if animated, it will return no changes