2022-07-08 01:33:29 -05:00

30 lines
753 B
TypeScript

import type { 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[]) {
this.components.push(...components);
return this;
}
setComponents(...components: T[]) {
this.components.splice(
0,
this.components.length,
...components,
);
return this;
}
toJSON() {
return { type: this.type, components: this.components.map((c) => c.toJSON()) };
}
}