Marcos Susaña 89c43eb3a5
Top level declarations (#56)
* chore(): declarations

* fixes

* fix a jk

* fix components

* fix
2022-07-15 18:03:23 +00:00

33 lines
904 B
TypeScript

import type { DiscordActionRow, MessageComponentTypes } from "../../../../discordeno/mod.ts";
import type { ComponentBuilder } from "../../../Util.ts";
export class ActionRowBuilder<T extends ComponentBuilder> {
constructor() {
this.components = [] as T[];
this.type = 1;
}
components: T[];
type: MessageComponentTypes.ActionRow;
addComponents(...components: T[]): ActionRowBuilder<T> {
this.components.push(...components);
return this;
}
setComponents(...components: T[]): ActionRowBuilder<T> {
this.components.splice(
0,
this.components.length,
...components,
);
return this;
}
toJSON(): DiscordActionRow {
return {
type: this.type,
components: this.components.map((c) => c.toJSON()) as DiscordActionRow["components"],
};
}
}