UNPKG

@evolvejs/core

Version:

An advanced Discord API wrapper with TS and JS support

141 lines (140 loc) 3.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EmbedBuilder = void 0; const __1 = require("../.."); class EmbedBuilder { constructor() { this.fields = []; } setTitle(title) { this.title = title; return this; } setType(type) { this.type = type; return this; } setDescription(description) { this.description = description; return this; } appendDescription(description) { this.description += description; return this; } setTimestamp(timestamp) { this.timestamp = timestamp; return this; } setURL(url) { this.url = url.toString(); return this; } setColor(color) { this.color = color; return this; } setThumbnail(url, proxyURL, height, width) { const thumbnail = new __1.EmbedThumbnailBuilder(); if (url) thumbnail.setURL(url); if (proxyURL) thumbnail.setProxyURL(proxyURL); if (height) thumbnail.setHeight(height); if (width) thumbnail.setWidth(width); this.thumbnail = thumbnail.build(); return this; } setVideo(url, height, width) { const video = new __1.EmbedVideoBuilder(); if (url) video.setURL(url); if (height) video.setHeight(height); if (width) video.setWidth(width); this.video = video.build(); return this; } setImage(url, proxyURL, height, width) { const image = new __1.EmbedImageBuilder(); if (url) image.setURL(url); if (proxyURL) image.setProxyURL(url); if (height) image.setHeight(height); if (width) image.setWidth(width); this.image = image.build(); return this; } setAuthor(text, url, iconURL, proxyIconURL) { const author = new __1.EmbedAuthorBuilder(); if (text) author.setName(text); if (url) author.setURL(url); if (iconURL) author.setIconURL(iconURL); if (proxyIconURL) author.setProxyIconURL(proxyIconURL); this.author = author.build(); return this; } setFooter(text, url, proxyURL) { const footer = new __1.EmbedFooterBuilder(); if (text) footer.setText(text); if (url) footer.setIconUrl(url); if (proxyURL) footer.setProxyIconUrl(proxyURL); this.footer = footer.build(); return this; } setProvider(name, url) { const provider = new __1.EmbedProviderBuilder(); if (name) provider.setName(name); if (url) provider.setURL(url); this.provider = provider.build(); return this; } addField(key, value, inline = false) { const field = new __1.EmbedFieldBuilder() .setName(key) .setValue(value) .enableInline(inline) .build(); this.fields.push(field); return this; } addFields(...fields) { for (const field of fields) { this.addField(field.key, field.value, field.inline); } return this; } build() { return { title: this.title, type: this.type, description: this.description, url: this.url, timestamp: this.timestamp, color: this.color, footer: this.footer, image: this.image, thumnail: this.thumbnail, video: this.video, provider: this.provider, author: this.author, fields: this.fields, }; } } exports.EmbedBuilder = EmbedBuilder;