MessageAttachment
classe · Source
Represents an attachment in a message.
Constructor
Parameters
| Name | Type | Description |
|---|---|---|
attachment | BufferResolvable | Stream | The file |
name? | string | The name of the file, if any Default: null. |
data? | APIAttachment | Extra data |
Properties
name
nullable
The name of this attachment Source
id
The attachment's id Source
size
The size of this attachment in bytes Source
url
The URL to this attachment Source
proxyURL
The Proxy URL to this attachment Source
height
nullable
The height of this attachment (if an image or video) Source
width
nullable
The width of this attachment (if an image or video) Source
contentType
nullable
The media (MIME) type of this attachment Source
description
nullable
The description (alt text) of this attachment Source
ephemeral
Whether this attachment is ephemeral Source
duration
nullable
The duration of this attachment in seconds This will only be available if the attachment is an audio file. Source
waveform
nullable
The base64 encoded byte array representing a sampled waveform This will only be available if the attachment is an audio file. Source
flags
The flags of this attachment Source
title
nullable
The title of this attachment This will only be available if the attachment name contains special characters. Source
spoiler
readonly
Whether or not this attachment has been marked as a spoiler Source
Methods
setDescription
Sets the description of this attachment. Parameters
| Name | Type | Description |
|---|---|---|
description | string | The description of the file |
Returns: MessageAttachment — This attachment Source
setFile
Sets the file of this attachment. Parameters
| Name | Type | Description |
|---|---|---|
attachment | BufferResolvable | Stream | The file |
name? | string | The name of the file, if any Default: null. |
Returns: MessageAttachment — This attachment Source
setName
Sets the name of this attachment. Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the file |
Returns: MessageAttachment — This attachment Source
setTitle
Sets the title of this attachment. Parameters
| Name | Type | Description |
|---|---|---|
title | string | The title of the file |
Returns: MessageAttachment — This attachment Source
setWaveform
Sets the sampled waveform for a voice message attachment. Parameters
| Name | Type | Description |
|---|---|---|
waveform | string | The base64 encoded sampled waveform |
Returns: MessageAttachment — This attachment Source
setDuration
Sets the duration of a voice message attachment. Parameters
| Name | Type | Description |
|---|---|---|
duration | number | The duration in seconds |
Returns: MessageAttachment — This attachment Source
setSpoiler
Sets whether this attachment is a spoiler Parameters
| Name | Type | Description |
|---|---|---|
spoiler? | boolean | Whether the attachment should be marked as a spoiler Default: true. |
Returns: MessageAttachment — This attachment Source