Class

AttachmentBuilder

Attachment metadata for message payloads (file bytes sent separately).

Constructor

new AttachmentBuilder(id: number, filename: string, options?: Partial<AttachmentPayloadOptions>)
ParamTypeDescription
idnumber
filenamestring
options?Partial<AttachmentPayloadOptions>

Properties

description?: string | null

Alt text / description for accessibility.

filename: string

Filename (may be prefixed with `SPOILER_` if spoiler is true).

id: number (readonly)

Attachment ID (index in files array).

spoiler: boolean

Whether this attachment should be hidden until clicked.

Methods

setDescription(description: string | null): this

Set attachment description (alt text for accessibility). Pass null to clear.

ParamTypeDescription
descriptionstring | null

Description text or null

setName(name: string): this

Set attachment filename (preserves spoiler prefix if enabled).

ParamTypeDescription
namestring

New filename

setSpoiler(spoiler: boolean): this

Toggle spoiler flag (adds/removes `SPOILER_` prefix from filename).

ParamTypeDescription
spoilerboolean

Whether this attachment should be hidden

Serialize to API attachment payload.