class FileBuilder
extends
ComponentBuilder<APIFileComponent>export declare class FileBuilder extends ComponentBuilder<APIFileComponent>A builder that creates API-compatible JSON data for files.
Constructors
constructor(data?: Partial<APIFileComponent>)
data?: Partial<APIFileComponent>
Creates a new file.
Examples:Creating a file from an API data object:Creating a file using setters and API data:
const file = new FileBuilder({
spoiler: true,
file: {
url: 'attachment://file.png',
},
});const file = new FileBuilder({
file: {
url: 'attachment://image.jpg',
},
})
.setSpoiler(false);Clears the id of this component, defaulting to a default incremented id.
Inherited from: ComponentBuilder
setSpoiler(spoiler?: boolean) : this
spoiler?: boolean
Sets the spoiler status of this file.
setURL(url: string) : this
url: string
Sets the media URL of this file.
toJSON(validationOverride?: boolean) : APIFileComponent
validationOverride?: boolean
Serializes this builder to API-compatible JSON data.Note that by disabling validation, there is no guarantee that the resulting object will be valid.