mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
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>
This commit is contained in:
@@ -1,12 +1,33 @@
|
||||
import type { APIMessageComponent, ComponentType } from 'discord-api-types/v9';
|
||||
import type { JSONEncodable } from '../util/jsonEncodable';
|
||||
import type { APIBaseMessageComponent, APIMessageComponent, ComponentType } from 'discord-api-types/v9';
|
||||
|
||||
/**
|
||||
* Represents a discord component
|
||||
*/
|
||||
export interface Component extends JSONEncodable<APIMessageComponent> {
|
||||
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
|
||||
*/
|
||||
readonly type: ComponentType;
|
||||
public get type(): DataType['type'] {
|
||||
return this.data.type;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user