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
ProtectedReadonly
clearId():this
Clears the id of this component, defaulting to a default incremented id.
Inherited from ComponentBuilder
setId(id):this
Sets the id of this component.
NameTypeOptionalDescription
idnumberNoThe id to use
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
toJSON(validationOverride?):APIFileComponent
Serializes this builder to API-compatible JSON data.Note that by disabling validation, there is no guarantee that the resulting object will be valid.
NameTypeOptionalDescription
validationOverridebooleanYesForce validation to run/not run regardless of your global preference