Skip to content

MessageAttachment ​

classe · Source

Represents an attachment in a message.

Constructor ​

new MessageAttachment(attachment: BufferResolvable | Stream, name?: string, data?: APIAttachment)

Parameters

NameTypeDescription
attachmentBufferResolvable | StreamThe file
name?stringThe name of the file, if any Default: null.
data?APIAttachmentExtra data

Properties ​

name ​

nullable

name: string

The name of this attachment Source

id ​

id: Snowflake

The attachment's id Source

size ​

size: number

The size of this attachment in bytes Source

url ​

url: string

The URL to this attachment Source

proxyURL ​

proxyURL: string

The Proxy URL to this attachment Source

height ​

nullable

height: number

The height of this attachment (if an image or video) Source

width ​

nullable

width: number

The width of this attachment (if an image or video) Source

contentType ​

nullable

contentType: string

The media (MIME) type of this attachment Source

description ​

nullable

description: string

The description (alt text) of this attachment Source

ephemeral ​

ephemeral: boolean

Whether this attachment is ephemeral Source

duration ​

nullable

duration: number

The duration of this attachment in seconds This will only be available if the attachment is an audio file. Source

waveform ​

nullable

waveform: string

The base64 encoded byte array representing a sampled waveform This will only be available if the attachment is an audio file. Source

flags ​

flags: Readonly<AttachmentFlags>

The flags of this attachment Source

title ​

nullable

title: string

The title of this attachment This will only be available if the attachment name contains special characters. Source

spoiler ​

readonly

spoiler: boolean

Whether or not this attachment has been marked as a spoiler Source

Methods ​

setDescription ​

setDescription(description: string): MessageAttachment

Sets the description of this attachment. Parameters

NameTypeDescription
descriptionstringThe description of the file

Returns: MessageAttachment — This attachment Source

setFile ​

setFile(attachment: BufferResolvable | Stream, name?: string): MessageAttachment

Sets the file of this attachment. Parameters

NameTypeDescription
attachmentBufferResolvable | StreamThe file
name?stringThe name of the file, if any Default: null.

Returns: MessageAttachment — This attachment Source

setName ​

setName(name: string): MessageAttachment

Sets the name of this attachment. Parameters

NameTypeDescription
namestringThe name of the file

Returns: MessageAttachment — This attachment Source

setTitle ​

setTitle(title: string): MessageAttachment

Sets the title of this attachment. Parameters

NameTypeDescription
titlestringThe title of the file

Returns: MessageAttachment — This attachment Source

setWaveform ​

setWaveform(waveform: string): MessageAttachment

Sets the sampled waveform for a voice message attachment. Parameters

NameTypeDescription
waveformstringThe base64 encoded sampled waveform

Returns: MessageAttachment — This attachment Source

setDuration ​

setDuration(duration: number): MessageAttachment

Sets the duration of a voice message attachment. Parameters

NameTypeDescription
durationnumberThe duration in seconds

Returns: MessageAttachment — This attachment Source

setSpoiler ​

setSpoiler(spoiler?: boolean): MessageAttachment

Sets whether this attachment is a spoiler Parameters

NameTypeDescription
spoiler?booleanWhether the attachment should be marked as a spoiler Default: true.

Returns: MessageAttachment — This attachment Source

Unofficial software. Not affiliated with or supported by Discord.