Class
AttachmentBuilder
Attachment metadata for message payloads (file bytes sent separately).
Constructor
new AttachmentBuilder
(id: number, filename: string, options?: Partial<AttachmentPayloadOptions>)| Param | Type | Description |
|---|---|---|
| id | number | |
| filename | string | |
| options? | Partial<AttachmentPayloadOptions> |
Properties
description
?: string | nullAlt text / description for accessibility.
filename
: stringFilename (may be prefixed with `SPOILER_` if spoiler is true).
id
: number (readonly)Attachment ID (index in files array).
spoiler
: booleanWhether this attachment should be hidden until clicked.
Methods
setDescription
(description: string | null): thisSet attachment description (alt text for accessibility). Pass null to clear.
| Param | Type | Description |
|---|---|---|
| description | string | null | Description text or null |
setName
(name: string): thisSet attachment filename (preserves spoiler prefix if enabled).
| Param | Type | Description |
|---|---|---|
| name | string | New filename |
setSpoiler
(spoiler: boolean): thisToggle spoiler flag (adds/removes `SPOILER_` prefix from filename).
| Param | Type | Description |
|---|---|---|
| spoiler | boolean | Whether this attachment should be hidden |
toJSON
(): APIAttachmentPayloadSerialize to API attachment payload.