Skip to content

GramIO API Reference / @gramio/contexts/dist / DownloadMixin

Class: DownloadMixin<Bot> ​

Defined in: contexts/index.d.ts:5944

This object represents a mixin that can be used to download media files

Extends ​

Extended by ​

Type Parameters ​

Type Parameter
Bot extends BotLike

Constructors ​

Constructor ​

new DownloadMixin<Bot>(): DownloadMixin<Bot>

Returns ​

DownloadMixin<Bot>

Inherited from ​

Context.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
botpublicBotContext.botcontexts/index.d.ts:5240
update?publicTelegramUpdateContext.updatecontexts/index.d.ts:5242
updateId?publicnumberContext.updateIdcontexts/index.d.ts:5241
updateTypeprotectedUpdateNameContext.updateTypecontexts/index.d.ts:5243

Accessors ​

[toStringTag] ​

Get Signature ​

get [toStringTag](): string

Defined in: contexts/index.d.ts:5246

MDN

Returns ​

string

Inherited from ​

Context.[toStringTag]


attachment ​

Get Signature ​

get attachment(): Attachment

Defined in: contexts/index.d.ts:5941

Returns ​

Attachment

Methods ​

download() ​

Call Signature ​

download(): FileDownload

Defined in: contexts/index.d.ts:5959

Download the message's attachment.

Returns a lazy, Response-like FileDownload handle — await it for an ArrayBuffer, or call .bytes() / .text() / .json() / .blob() / .stream() / .toFile(path) / .link() / .info(). Pass path to save straight to disk.

Returns ​

FileDownload

Example ​
ts
await ctx.download().toFile("./photo.jpg");
const text = await ctx.download().text();

Call Signature ​

download(path): Promise<string>

Defined in: contexts/index.d.ts:5960

Download the message's attachment.

Returns a lazy, Response-like FileDownload handle — await it for an ArrayBuffer, or call .bytes() / .text() / .json() / .blob() / .stream() / .toFile(path) / .link() / .info(). Pass path to save straight to disk.

Parameters ​
ParameterType
pathstring
Returns ​

Promise<string>

Example ​
ts
await ctx.download().toFile("./photo.jpg");
const text = await ctx.download().text();

is() ​

is<T>(rawTypes): this is InstanceType<ContextsMapping<Bot>[T]> & GetDerives<Bot, T> & (IsAny<Bot["__Derives"]> extends true ? {} : Bot["__Derives"] extends {} ? Bot["__Derives"]["global"] & Bot["__Derives"][T] : {})

Defined in: contexts/index.d.ts:5249

Type Parameters ​

Type Parameter
T extends UpdateName

Parameters ​

ParameterType
rawTypesMaybeArray<SoftString<T>>

Returns ​

this is InstanceType<ContextsMapping<Bot>[T]> & GetDerives<Bot, T> & (IsAny<Bot["__Derives"]> extends true ? {} : Bot["__Derives"] extends {} ? Bot["__Derives"]["global"] & Bot["__Derives"][T] : {})

Inherited from ​

Context.is