File

discord_http.file module

class discord_http.file.File(data, filename=None, *, spoiler=False, title=None, description=None, duration_secs=None, waveform=None)

Bases: object

Represents a file to be uploaded to Discord.

Parameters:
data

The file data as a file-like object.

Type:

io.BufferedIOBase

spoiler

Whether the file is a spoiler.

Type:

bool

title

The title of the file, if any.

Type:

str | None

description

The description of the file, if any.

Type:

str | None

duration_secs

The duration of the file in seconds, if applicable.

Type:

int | None

waveform

The waveform data for the file, if applicable.

Type:

str | None

close() None

Close the file buffer.

Return type:

None

property filename: str

The filename of the file.

reset(*, seek=True) None

Reset the file buffer to the original position.

Return type:

None

Parameters:

seek (int | bool)

to_dict(index) dict

The file as a dictionary.

Parameters:

index (int) – The index of the file

Return type:

dict

Returns:

The file as a dictionary