/
EmbedBuilder.js
40 lines (34 loc) · 1002 Bytes
/
EmbedBuilder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const { EmbedBuilder: BuildersEmbed, isJSONEncodable } = require('@discordjs/builders');
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/main/EmbedBuilder:Class}
*/