FileBuilder

export declare class FileBuilder extends ComponentBuilder<APIFileComponent>
export declare class FileBuilder extends ComponentBuilder<APIFileComponent>

No summary provided.

constructor(data?)
Creates a new file from API data.
Example
Creating a file from an API data object:
const file = new FileBuilder({
spoiler: true,
file: {
url: 'attachment://file.png',
},
});
const file = new FileBuilder({
spoiler: true,
file: {
url: 'attachment://file.png',
},
});
Example
Creating a file using setters and API data:
const file = new FileBuilder({
file: {
url: 'attachment://image.jpg',
},
})
.setSpoiler(false);
const file = new FileBuilder({
file: {
url: 'attachment://image.jpg',
},
})
.setSpoiler(false);
NameTypeOptionalDescription
dataPartial<APIFileComponent>YesThe API data to create this file with
The API data associated with this component.
Inherited from ComponentBuilder
clearId():this
Clears the id of this component, defaulting to a default incremented id.
Inherited from ComponentBuilder
setId(id):this
Sets the id (not the custom id) for this component.
NameTypeOptionalDescription
idnumberNoThe id for this component
Inherited from ComponentBuilder
setSpoiler(spoiler?):this
Sets the spoiler status of this file.
NameTypeOptionalDescription
spoilerbooleanYesThe spoiler status to use
setURL(url):this
Sets the media URL of this file.
NameTypeOptionalDescription
urlstringNoThe URL to use
Serializes this builder to API-compatible JSON data.
Remarks
This method runs validations on the data before serializing it. As such, it may throw an error if the data is invalid.