Skip to content

AttachmentBuilder

Package: @erinjs/builders

Builder for attachment metadata (filename, description, spoiler). Actual file data is passed separately when sending.

Constructor

NameTypeOptionalDescription
idnumberNoIndex of the attachment (0-based). Must match the FormData part order.
filenamestringNo
optionsPartial<AttachmentPayloadOptions>Yes

Properties

NameTypeReadonlyOptionalDescription
descriptionstring | nullNoYes
filenamestringNoNo
idnumberYesNo
spoilerbooleanNoNo

Methods

setDescription()

Set the attachment description (alt text).

Returns: this

Parameters:

NameTypeOptionalDescription
descriptionstring | nullNo

setName()

Set the displayed filename.

Returns: this

Parameters:

NameTypeOptionalDescription
namestringNo

setSpoiler()

Mark the attachment as a spoiler (blurred until clicked).

Returns: this

Parameters:

NameTypeOptionalDescription
spoilerbooleanNo

toJSON()

Convert to API format for MessagePayload.

Returns: APIAttachmentPayload

Parameters:

None

Released under the Apache-2.0 License.