hennus-api
Version:
Esta es una libreria para el bot Hennus
76 lines (75 loc) • 2.23 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmbedBuilder = void 0;
const utils_1 = require("../utils");
class EmbedBuilder {
constructor(options) {
this.type = "rich";
this.color = (0, utils_1.resolvedColor)("Default");
this.fields = [];
this.title = options?.title;
this.description = options?.description;
this.url = options?.url;
this.timestamp = options?.timestamp ?? undefined;
this.color = (0, utils_1.resolvedColor)(options?.color ?? "Default");
this.footer = options?.footer;
this.image = typeof options?.image === "string" ? { url: options?.image } : options?.image;
this.thumbnail = typeof options?.thumbnail === "string" ? { url: options?.thumbnail } : options?.thumbnail;
this.author = options?.author;
this.save(options?.fields);
}
setTitle(value) {
this.title = value;
return this;
}
setDescription(value) {
this.description = value;
return this;
}
setURL(url) {
this.url = url;
return this;
}
setTimestamp(time) {
this.timestamp = time?.toISOString() ?? new Date(Date.now()).toISOString();
return this;
}
setColor(color) {
this.color = (0, utils_1.resolvedColor)(color);
return this;
}
setFooter(option) {
this.footer = option;
return this;
}
setImage(option) {
this.image = typeof option === "string" ? { url: option } : option;
return this;
}
setThumbnail(option) {
this.thumbnail = typeof option === "string" ? { url: option } : option;
return this;
}
setAuthor(option) {
this.author = option;
return this;
}
setFields(fields) {
this.fields = fields ?? [];
return this;
}
addFields(fields) {
this.save(fields);
return this;
}
addField(name, value, inline) {
this.save([{ name, value, inline }]);
return this;
}
save(fields) {
if (fields && Array.isArray(fields)) {
this.fields?.push(...fields);
}
}
}
exports.EmbedBuilder = EmbedBuilder;