AttachmentBuilder
Signature
export declare class AttachmentBuilderProperties
2Methods
6Properties
data: Partial<AttachmentData>;spoilerGetterget spoiler(): boolean;Gets whether the attachment is a spoiler.
Methods
constructorConstructorconstructor(data?: Partial<AttachmentData>);setName(name: string): this;Sets the name of the attachment.
Parameters
name- The name of the attachment.
Returns
The Attachment instance.
Examples
attachment.setName('example.jpg');setDescription(desc: string): this;Sets the description of the attachment.
Parameters
desc- The description of the attachment.
Returns
The Attachment instance.
Examples
attachment.setDescription('This is an example attachment');setFile<T extends AttachmentDataType = AttachmentDataType>(type: T, data: AttachmentResolvableMap[T]): this;Sets the file data of the attachment.
Parameters
type- The type of the attachment data.
data- The resolvable data of the attachment.
Returns
The Attachment instance.
Examples
attachment.setFile('url', 'https://example.com/example.jpg');
attachment.setFile('path', '../assets/example.jpg');
attachment.setFile('buffer', Buffer.from(image.decode()));setSpoiler(spoiler: boolean): this;Sets whether the attachment is a spoiler.
Parameters
spoiler- Whether the attachment is a spoiler.
Returns
The Attachment instance.
Examples
attachment.setSpoiler(true);toJSON(): AttachmentData;Converts the Attachment instance to JSON.
Returns
The JSON representation of the Attachment instance.