This commit is contained in:
tungdo0602
2025-06-29 12:56:55 +07:00
parent 1aa4f523ad
commit 767b72182e
8 changed files with 144 additions and 7 deletions

View File

@@ -5,16 +5,39 @@ const { MessageComponentTypes } = require('../util/Constants');
class ContainerComponent extends BaseMessageComponent {
/**
*
* @param {*} data
* @typedef {MessageActionRow|TextDisplayComponent|SectionComponent|MediaGalleryComponent|SeparatorComponent|FileComponent} ContainerComponents
* @property {ContainerComponents[]} [components] Components of the type action row, text display, section, media gallery, separator, or file
* @property {Number} [accent_color] Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF
* @property {Boolean} [spoiler] Whether the container should be a spoiler (or blurred out). Defaults to false.
*/
/**
* @param {} [data={}]
*/
constructor(data = {}) {
super({ type: 'CONTAINER' }, data);
/**
* Components of the type action row, text display, section, media gallery, separator, or file
* @type {ContainerComponents[]}
*/
this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? null;
/**
* Color for the accent on the container as RGB from 0x000000 to 0xFFFFFF
* @type {Number}
*/
this.accent_color = data.accent_color ?? null;
/**
* Whether the container should be a spoiler (or blurred out). Defaults to false.
* @type {Boolean}
*/
this.spoiler = data.spoiler ?? false;
}
/**
* @returns {APIContainerComponent}
*/
toJSON() {
return {
type: MessageComponentTypes[this.type],