seyfert/src/components/Section.ts
Marcos Susaña 589a59c5f6
feat: components V2 (#337)
* feat: components v2

* fix: build

* chore: apply formatting

* refactor(components): some types

* refactor(types): replace TopLevelComponents with APITopLevelComponent in REST

* fix: unify components

* refactor(TextDisplay): rename content method to setContent for clarity

* refactor(builders): add missing builder from component

* fix: touche

* feat(webhook): webhook params for components v2

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-25 00:10:09 -04:00

24 lines
879 B
TypeScript

import { componentFactory } from '.';
import type { APISectionComponent, ComponentType } from '../types';
import { BaseComponent } from './BaseComponent';
import type { ButtonComponent } from './ButtonComponent';
import type { TextDisplayComponent } from './TextDisplay';
import type { ThumbnailComponent } from './Thumbnail';
export class SectionComponent extends BaseComponent<ComponentType.Section> {
protected _components: TextDisplayComponent[];
protected _accessory: ThumbnailComponent | ButtonComponent;
constructor(data: APISectionComponent) {
super(data);
this._components = data.components?.map(componentFactory) as TextDisplayComponent[];
this._accessory = componentFactory(data.accessory) as ThumbnailComponent | ButtonComponent;
}
get components() {
return this._components;
}
get accessory() {
return this._accessory;
}
}