mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Co-authored-by: Naiyar <137700126+imnaiyar@users.noreply.github.com> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Vlad Frangu <me@vladfrangu.dev> Co-authored-by: Timo <mail@geniustimo.de>
41 lines
790 B
JavaScript
41 lines
790 B
JavaScript
'use strict';
|
|
|
|
const Component = require('./Component');
|
|
const UnfurledMediaItem = require('./UnfurledMediaItem');
|
|
|
|
/**
|
|
* Represents a file component
|
|
* @extends {Component}
|
|
*/
|
|
class FileComponent extends Component {
|
|
constructor({ file, ...data }) {
|
|
super(data);
|
|
|
|
/**
|
|
* The media associated with this file
|
|
* @type {UnfurledMediaItem}
|
|
* @readonly
|
|
*/
|
|
this.file = new UnfurledMediaItem(file);
|
|
}
|
|
|
|
/**
|
|
* Whether this thumbnail is spoilered
|
|
* @type {boolean}
|
|
* @readonly
|
|
*/
|
|
get spoiler() {
|
|
return this.data.spoiler ?? false;
|
|
}
|
|
|
|
/**
|
|
* Returns the API-compatible JSON for this component
|
|
* @returns {APIFileComponent}
|
|
*/
|
|
toJSON() {
|
|
return { ...this.data, file: this.file.toJSON() };
|
|
}
|
|
}
|
|
|
|
module.exports = FileComponent;
|