v2componentsbuilder
Version:
A discord.js v2components builder
59 lines (58 loc) • 1.89 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.V2RoleSelectBuilder = void 0;
const v10_1 = require("discord-api-types/v10");
class V2RoleSelectBuilder {
constructor() { }
setCustomId(custom_id) {
if (custom_id.length > 100)
throw new Error("Max length for custom_id is 100 characters");
this.custom_id = custom_id;
return this;
}
setPlaceholder(placeholder) {
if (placeholder.length > 150)
throw new Error("Max length for placeholder is 150 characters");
this.placeholder = placeholder;
return this;
}
setMinValues(min) {
if (min < 0 || min > 25)
throw new Error("min_values must be between 0 and 25");
this.min_values = min;
return this;
}
setMaxValues(max) {
if (max < 1 || max > 25)
throw new Error("max_values must be between 1 and 25");
this.max_values = max;
return this;
}
setDisabled(disabled) {
this.disabled = disabled;
return this;
}
setDefaultValues(values) {
if (values.length > 25)
throw new Error("Cannot have more than 25 default values");
this.default_values = values.map((val) => ({
id: val.id,
type: v10_1.SelectMenuDefaultValueType.Role
}));
return this;
}
toJSON() {
if (!this.custom_id)
throw new Error("custom_id is required");
return {
type: v10_1.ComponentType.RoleSelect,
custom_id: this.custom_id,
placeholder: this.placeholder,
default_values: this.default_values,
min_values: this.min_values,
max_values: this.max_values,
disabled: this.disabled ?? false
};
}
}
exports.V2RoleSelectBuilder = V2RoleSelectBuilder;
;