hennus-api
Version:
Esta es una libreria para el bot Hennus
45 lines (44 loc) • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModalBuilder = void 0;
const v10_1 = require("discord-api-types/v10");
const actionrow_1 = require("./actionrow");
class ModalBuilder {
constructor(options) {
this.title = options?.title;
this.custom_id = options?.custom_id;
this.components = [];
if (options?.components) {
this.setComponents(options.components);
}
}
setTitle(title) {
this.title = title;
return this;
}
setCustomId(custom_id) {
this.custom_id = custom_id;
return this;
}
addTextInputComponents(components) {
for (const component of components) {
if (!this.findComponentById(component.custom_id ?? "", v10_1.ComponentType.Button)) {
this.components.push(new actionrow_1.ActionRowBuilder().AddComponent(component));
}
}
return this;
}
setComponents(components, limitRows) {
const data = limitRows ? components.slice(0, limitRows) : components;
this.components = data;
return this;
}
addComponent(component) {
this.components.push(new actionrow_1.ActionRowBuilder().AddComponent(component));
return this;
}
findComponentById(customId, type) {
return this.components.find((actionRow) => actionRow.components.some((comp) => comp.type === type && comp.custom_id === customId));
}
}
exports.ModalBuilder = ModalBuilder;