UNPKG

hennus-api

Version:

Esta es una libreria para el bot Hennus

75 lines (74 loc) 2.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SelectMenuBuilder = void 0; const v10_1 = require("discord-api-types/v10"); class SelectMenuBuilder { constructor(options) { this.options = []; this.custom_id = options?.custom_id; this.SetType(options?.type ?? v10_1.ComponentType.StringSelect); if (options?.type == v10_1.ComponentType.StringSelect && options?.options) { this.save(options.options); } else if (options?.type == v10_1.ComponentType.ChannelSelect) { this.channel_types = options?.channel_types; } this.placeholder = options?.placeholder; this.min_values = options?.min_values; this.max_values = options?.max_values; this.disabled = options?.disabled; } SetCustomId(custom) { this.custom_id = custom; return this; } SetType(type) { const typeMap = { "Text": v10_1.ComponentType.StringSelect, "User": v10_1.ComponentType.UserSelect, "Role": v10_1.ComponentType.RoleSelect, "Channels": v10_1.ComponentType.ChannelSelect, "Mentionable": v10_1.ComponentType.MentionableSelect }; this.type = typeof type === "number" ? type : typeMap[type] ?? 3; return this; } SetPlaceHolder(text) { this.placeholder = text; return this; } SetOptions(options) { this.options = options; return this; } AddOptions(options) { this.save(options); return this; } AddOption(option) { this.save([option]); return this; } SetChannelTypes(channel_types) { this.channel_types = channel_types; return this; } SetMinValues(values) { this.min_values = typeof values === "number" ? Math.min(values, 25) : undefined; return this; } SetMaxValues(values) { this.max_values = typeof values === "number" ? Math.min(values, 25) : undefined; return this; } SetDisabled(disabled) { this.disabled = disabled; return this; } save(options) { if (this.type === 3 && options) { this.options.push(...options); } } } exports.SelectMenuBuilder = SelectMenuBuilder;