component v2

This commit is contained in:
TotallyTung
2025-06-23 22:04:53 +07:00
committed by GitHub
parent 714f8bd5de
commit 7a2a3d7a05
12 changed files with 250 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
'use strict';
const BaseMessageComponent = require('./BaseMessageComponent');
const { MessageComponentTypes } = require('../util/Constants');
class ContainerComponent extends BaseMessageComponent {
constructor(data = {}) {
super({ type: 'CONTAINER' });
this.components = data.components?.map(c => BaseMessageComponent.create(c)) ?? null;
this.accent_color = data.accent_color ?? null;
this.spoiler = data.spoiler ?? false;
}
toJSON() {
return {
type: MessageComponentTypes[this.type],
components: this.components.map(c => c.toJSON()),
accent_color: this.accent_color,
spoiler: this.spoiler,
};
}
}
module.exports = ContainerComponent;