refactor(EmbedBuilder): allow hex strings in setColor (#7673)

* refactor(EmbedBuilder): allow hex strings in setColor

* Apply suggestions from code review

Co-authored-by: Almeida <almeidx@pm.me>

Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
Ben
2022-03-15 13:29:19 -07:00
committed by GitHub
parent 2297c2b947
commit f4729759f6

View File

@@ -2,6 +2,7 @@
const { EmbedBuilder: BuildersEmbed, isJSONEncodable } = require('@discordjs/builders');
const Transformers = require('../util/Transformers');
const Util = require('../util/Util');
class EmbedBuilder extends BuildersEmbed {
constructor(data) {
@@ -19,6 +20,18 @@ class EmbedBuilder extends BuildersEmbed {
}
return new this(other);
}
/**
* Sets the color of this embed
* @param {?ColorResolvable} color The color of the embed
* @returns {Embed}
*/
setColor(color) {
if (color === null) {
return super.setColor(null);
}
return super.setColor(Util.resolveColor(color));
}
}
module.exports = EmbedBuilder;