Files
discord.js/packages/discord.js/src/structures/EmbedBuilder.js
2023-05-01 22:25:51 +00:00

42 lines
1.0 KiB
JavaScript

'use strict';
const { EmbedBuilder: BuildersEmbed } = require('@discordjs/builders');
const { isJSONEncodable } = require('@discordjs/util');
const { toSnakeCase } = require('../util/Transformers');
const { resolveColor } = require('../util/Util');
/**
* Represents an embed builder.
* @extends {BuildersEmbed}
*/
class EmbedBuilder extends BuildersEmbed {
constructor(data) {
super(toSnakeCase(data));
}
/**
* Sets the color of this embed
* @param {?ColorResolvable} color The color of the embed
* @returns {EmbedBuilder}
*/
setColor(color) {
return super.setColor(color && resolveColor(color));
}
/**
* Creates a new embed builder from JSON data
* @param {EmbedBuilder|Embed|APIEmbed} other The other data
* @returns {EmbedBuilder}
*/
static from(other) {
return new this(isJSONEncodable(other) ? other.toJSON() : other);
}
}
module.exports = EmbedBuilder;
/**
* @external BuildersEmbed
* @see {@link https://discord.js.org/docs/packages/builders/stable/EmbedBuilder:Class}
*/