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
Context<Bot>.DownloadMixinMetadata
Extended by
Type Parameters
| Type Parameter |
|---|
Bot extends BotLike |
Constructors
Constructor
new DownloadMixin<
Bot>():DownloadMixin<Bot>
Returns
DownloadMixin<Bot>
Inherited from
Properties
| Property | Modifier | Type | Inherited from | Defined in |
|---|---|---|---|---|
bot | public | Bot | Context.bot | contexts/index.d.ts:5240 |
update? | public | TelegramUpdate | Context.update | contexts/index.d.ts:5242 |
updateId? | public | number | Context.updateId | contexts/index.d.ts:5241 |
updateType | protected | UpdateName | Context.updateType | contexts/index.d.ts:5243 |
Accessors
[toStringTag]
Get Signature
get [toStringTag]():
string
Defined in: contexts/index.d.ts:5246
Returns
string
Inherited from
attachment
Get Signature
get attachment():
Attachment
Defined in: contexts/index.d.ts:5941
Returns
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
Example
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
| Parameter | Type |
|---|---|
path | string |
Returns
Promise<string>
Example
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
| Parameter | Type |
|---|---|
rawTypes | MaybeArray<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] : {})