Files
discord.js/packages/builders/src/components/Component.ts
Suneet Tipirneni e8252ed3b9 refactor: make public builder props getters (#7422)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
2022-02-13 13:06:11 +01:00

34 lines
816 B
TypeScript

import type { JSONEncodable } from '../util/jsonEncodable';
import type { APIBaseMessageComponent, APIMessageComponent, ComponentType } from 'discord-api-types/v9';
/**
* Represents a discord component
*/
export abstract class Component<
DataType extends Partial<APIBaseMessageComponent<ComponentType>> & {
type: ComponentType;
} = APIBaseMessageComponent<ComponentType>,
> implements JSONEncodable<APIMessageComponent>
{
/**
* The API data associated with this component
*/
protected readonly data: DataType;
/**
* Converts this component to an API-compatible JSON object
*/
public abstract toJSON(): APIMessageComponent;
public constructor(data: DataType) {
this.data = data;
}
/**
* The type of this component
*/
public get type(): DataType['type'] {
return this.data.type;
}
}