Files
discord.js-selfbot/src/structures/ThumbnailComponent.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2025-06-23 22:04:53 +07:00
'use strict';
const BaseMessageComponent = require('./BaseMessageComponent');
2025-06-24 11:31:41 +07:00
const UnfurledMediaItem = require('./UnfurledMediaItem');
2025-06-23 22:04:53 +07:00
const { MessageComponentTypes } = require('../util/Constants');
class ThumbnailComponent extends BaseMessageComponent {
2025-06-29 14:33:00 +07:00
/**
* @property {UnfurledMediaItem} [media] A url or attachment
2025-06-30 21:53:29 +07:00
* @property {String} [description] Alt text for the media, max 1024 characters
2025-06-29 14:33:00 +07:00
* @property {Boolean} [spoiler] Whether the thumbnail should be a spoiler (or blurred out). Defaults to false
*/
/**
2025-06-30 21:57:54 +07:00
* @param {ThumbnailComponent | APIThumbnailComponent} [data={}] The data
2025-06-29 14:33:00 +07:00
*/
2025-06-23 22:04:53 +07:00
constructor(data = {}) {
2025-06-24 12:32:58 +07:00
super({ type: 'THUMBNAIL' }, data);
2025-06-30 21:53:29 +07:00
/**
* A url or attachment
* @type {UnfurledMediaItem}
*/
2025-06-29 14:33:00 +07:00
this.media = new UnfurledMediaItem(data.media);
2025-06-30 21:53:29 +07:00
/**
* Alt text for the media, max 1024 characters
* @type {String}
*/
2025-06-23 22:04:53 +07:00
this.description = data.description ?? null;
2025-06-30 21:53:29 +07:00
/**
* Whether the thumbnail should be a spoiler (or blurred out). Defaults to false
* @type {Boolean}
*/
2025-06-23 22:04:53 +07:00
this.spoiler = data.spoiler ?? false;
}
2025-06-29 14:33:00 +07:00
/**
* @returns {APIThumbnailComponent}
*/
2025-06-23 22:04:53 +07:00
toJSON() {
return {
type: MessageComponentTypes[this.type],
media: this.media.toJSON(),
description: this.description,
spoiler: this.spoiler,
};
}
}
module.exports = ThumbnailComponent;