mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
chore(builders): simplify types (#7784)
* chore(builders): simplify types * chore: removed uneeded partial
This commit is contained in:
@@ -3,37 +3,26 @@ import type {
|
||||
APIActionRowComponent,
|
||||
APIActionRowComponentTypes,
|
||||
APIBaseComponent,
|
||||
APIMessageActionRowComponent,
|
||||
APIMessageComponent,
|
||||
APIModalActionRowComponent,
|
||||
APIModalComponent,
|
||||
ComponentType,
|
||||
} from 'discord-api-types/v10';
|
||||
|
||||
export type AnyAPIActionRowComponent = APIActionRowComponentTypes | APIActionRowComponent<APIActionRowComponentTypes>;
|
||||
|
||||
/**
|
||||
* Represents a discord component
|
||||
*/
|
||||
export abstract class ComponentBuilder<
|
||||
DataType extends Partial<APIBaseComponent<ComponentType>> & {
|
||||
type: ComponentType;
|
||||
} = APIBaseComponent<ComponentType>,
|
||||
> implements
|
||||
JSONEncodable<
|
||||
| APIModalComponent
|
||||
| APIMessageComponent
|
||||
| APIActionRowComponent<APIModalActionRowComponent | APIMessageActionRowComponent>
|
||||
>
|
||||
DataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>,
|
||||
> implements JSONEncodable<AnyAPIActionRowComponent>
|
||||
{
|
||||
/**
|
||||
* The API data associated with this component
|
||||
*/
|
||||
public readonly data: DataType;
|
||||
public readonly data: Partial<DataType>;
|
||||
|
||||
public abstract toJSON():
|
||||
| APIActionRowComponentTypes
|
||||
| APIActionRowComponent<APIModalActionRowComponent | APIMessageActionRowComponent>;
|
||||
public abstract toJSON(): AnyAPIActionRowComponent;
|
||||
|
||||
public constructor(data: DataType) {
|
||||
public constructor(data: Partial<DataType>) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user