seyfert/src/builders/TextDisplay.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

41 lines
1.1 KiB
TypeScript

import { type APITextDispalyComponent, ComponentType } from '../types';
import { BaseComponentBuilder } from './Base';
/**
* Represents a text display component builder.
* Used to display simple text content.
* @example
* ```ts
* const text = new TextDisplay().content('Hello, world!');
* ```
*/
export class TextDisplay extends BaseComponentBuilder<APITextDispalyComponent> {
/**
* Constructs a new TextDisplay component.
* @param data Optional initial data for the text display component.
*/
constructor(data: Partial<APITextDispalyComponent> = {}) {
super({ type: ComponentType.TextDisplay, ...data });
}
/**
* Sets the ID for the text display component.
* @param id The ID to set.
* @returns The updated TextDisplay instance.
*/
setId(id: number) {
this.data.id = id;
return this;
}
/**
* Sets the text content to display.
* @param content The text content.
* @returns The updated TextDisplay instance.
*/
setContent(content: string) {
this.data.content = content;
return this;
}
}