-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Component.ts
38 lines (33 loc) · 939 Bytes
/
Component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import type { JSONEncodable } from '../util/jsonEncodable';
import type {
APIActionRowComponentTypes,
APIBaseComponent,
APIMessageComponent,
ComponentType,
} from 'discord-api-types/v9';
import type { Equatable } from '../util/equatable';
/**
* Represents a discord component
*/
export abstract class Component<
DataType extends Partial<APIBaseComponent<ComponentType>> & {
type: ComponentType;
} = APIBaseComponent<ComponentType>,
> implements JSONEncodable<APIMessageComponent>, Equatable<Component | APIActionRowComponentTypes>
{
/**
* The API data associated with this component
*/
public readonly data: DataType;
public abstract toJSON(): APIMessageComponent;
public abstract equals(other: Component | APIActionRowComponentTypes): boolean;
public constructor(data: DataType) {
this.data = data;
}
/**
* The type of this component
*/
public get type(): DataType['type'] {
return this.data.type;
}
}