@discord-additions/embed-builder
Version:
Some helpful additions to make creating embeds easier.
246 lines (245 loc) • 6.34 kB
TypeScript
import type { EmbedAuthorOptions, EmbedField, EmbedImageOptions, EmbedOptions } from "oceanic.js";
export default class EmbedBuilder {
/**
* create an embed builder instance (or multiple) from the provided json
*
* @param {(EmbedOptions | Array<EmbedOptions>)} json - the embed json - accepts singular & array
* @param {boolean} [forceSingular=false] - force a singular return when an array is supplied
* @returns {(EmbedBuilder | Array<EmbedBuilder>)}
*/
static loadFromJSON(json: EmbedOptions): EmbedBuilder;
static loadFromJSON<T extends boolean = false>(json: Array<EmbedOptions>, forceSingular?: T): T extends true ? EmbedBuilder : Array<EmbedBuilder>;
private json;
/**
* load json into this embed builder instance - use static loadFromJSON method
*
* @private
* @param {EmbedOptions} json - the json to load
* @returns {this}
*/
private load;
/**
* set the embed author
*
* @param {string} name - the name of the author
* @param {string} [iconURL] - an icon url for the author
* @param {string} [url] - a url for the author
* @returns {this}
*/
setAuthor(name: string, iconURL?: string, url?: string): this;
/**
* get the current author
*
* @returns {(EmbedAuthorOptions | undefined)}
*/
getAuthor(): EmbedAuthorOptions | undefined;
/**
* remove the current author
*
* @returns {this}
*/
removeAuthor(): this;
/**
* set the embed color
*
* @param {number} color - the color
* @returns {this}
*/
setColor(color: number): this;
/**
* get the current color
*
* @returns {(number | undefined)}
*/
getColor(): number | undefined;
/**
* remove the current color
*
* @returns {this}
*/
removeColor(): this;
/**
* set the embed description
*
* @param {...(string | Array<string>)} value - the description value
* @returns {this}
*/
setDescription(first: string | Array<string>, ...other: Array<(string | Array<string>)>): this;
/**
* get the current description
*
* @returns {(string | undefined)}
*/
getDescription(): string | undefined;
/**
* remove the current description
*
* @returns {this}
*/
removeDescription(): this;
/**
* add a field to the embed
*
* @param {string} name - the field name
* @param {string} value - the field value
* @param {boolean} [inline] - if the field should be inline
* @returns {this}
*/
addField(name: string, value: string, inline?: boolean): this;
/**
* add a blank field to the embed (zero width spaces)
*
* @param {boolean} [inline] - if the field should be inline
* @returns {this}
*/
addBlankField(inline?: boolean): this;
/**
* get the field at the specified index
*
* @param {number} index - the index of the field to get
* @returns {this}
*/
getField(index: number): EmbedField;
/**
* add multiple raw fields
*
* @param {...EmbedField} args - the fields to add
* @returns {this}
*/
addFields(...args: Array<EmbedField>): this;
/**
* get the current fields
*
* @returns {Array<EmbedField>}
*/
getFields(): EmbedField[];
/**
* set the embed footer
*
* @param {string} text - the text
* @param {string} [iconURL] - the icon url
* @returns {this}
*/
setFooter(text: string, iconURL?: string): this;
/**
* get the current footer
*
* @returns {(string | undefined)}
*/
getFooter(): import("oceanic.js").EmbedFooterOptions | undefined;
/**
* remove the current footer
*
* @returns {this}
*/
removeFooter(): this;
/**
* set the embed image
*
* @param {string} url - image url
* @returns {this}
*/
setImage(url: string): this;
/**
* get the current image
*
* @returns {(EmbedImageOptions | undefined)}
*/
getImage(): EmbedImageOptions | undefined;
/**
* remove the current image
*
* @returns {this}
*/
removeImage(): this;
/**
* set the embed thumbnail
*
* @param {string} url - thumbnail url
* @returns {this}
*/
setThumbnail(url: string): this;
/**
* get the current thumbnail
*
* @returns {(EmbedImageOptions | undefined)}
*/
getThumbnail(): EmbedImageOptions | undefined;
/**
* remove the current thumbnail
*
* @returns {this}
*/
removeThumbnail(): this;
/**
* set the embed timestamp
*
* @param {(string | Date | "now")} time - an iso timestamp, Date object, or "now"
* @returns {this}
*/
setTimestamp(time: string | Date | "now"): this;
/**
* get the current timestamp
*
* @returns {(string | undefined)}
*/
getTimestamp(): string | undefined;
/**
* get the current timestamp as a date object
*
* @returns {(Date | undefined)}
*/
getTimestampDate(): Date | undefined;
/**
* remove the current timestamp
*
* @returns {this}
*/
removeTimestamp(): this;
/**
* set the embed title
*
* @param {string} title - the title
* @returns {this}
*/
setTitle(title: string): this;
/**
* get the current title
*
* @returns {(string | undefined)}
*/
getTitle(): string | undefined;
/**
* remove the current title
*
* @returns {this}
*/
removeTitle(): this;
/**
* set the embed url
*
* @param {string} url - the url
* @returns {this}
*/
setURL(url: string): this;
/**
* get the current url
*
* @returns {(string | undefined)}
*/
getURL(): string | undefined;
/**
* remove the current url
*
* @returns {this}
*/
removeURL(): this;
/**
* convert this embed to a json object
*
* @param {boolean} array - if the returned value should be contained in an array
* @returns {(EmbedOptions | Array<EmbedOptions>)}
*/
toJSON(array: true): [EmbedOptions];
toJSON(array?: false): EmbedOptions;
}