move embed builder into util
This commit is contained in:
parent
e2b42d8f95
commit
69222b195b
1 changed files with 9 additions and 7 deletions
|
@ -3,6 +3,8 @@
|
||||||
* Link: https://github.com/riyacchi/chariot.js/blob/master/structures/ChariotEmbed.js
|
* Link: https://github.com/riyacchi/chariot.js/blob/master/structures/ChariotEmbed.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const Colours = require('../constants/colours.json');
|
||||||
|
|
||||||
class Embed {
|
class Embed {
|
||||||
constructor (data = {}) {
|
constructor (data = {}) {
|
||||||
this.fields = [];
|
this.fields = [];
|
||||||
|
@ -28,21 +30,21 @@ class Embed {
|
||||||
* @private
|
* @private
|
||||||
* @param {*} color Any color which can be resolved
|
* @param {*} color Any color which can be resolved
|
||||||
*/
|
*/
|
||||||
_resolveColor (color) {
|
_resolveColour (colour) {
|
||||||
if (typeof color === 'string') {
|
if (typeof colour === 'string') {
|
||||||
if (color === 'RANDOM') return Math.floor(Math.random() * (0xFFFFFF + 1));
|
if (colour === 'RANDOM') return Math.floor(Math.random() * (0xFFFFFF + 1));
|
||||||
color = Colors[color.toUpperCase()] || parseInt(color.replace('#', ''), 16);
|
colour = Colours[colour.toUpperCase()] || parseInt(colour.replace('#', ''), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
return color;
|
return colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the color of this Embed
|
* Set the color of this Embed
|
||||||
* @param {*} color Any color resolvable by this._resolveColor
|
* @param {*} color Any color resolvable by this._resolveColor
|
||||||
*/
|
*/
|
||||||
setColor (color) {
|
setColour (colour) {
|
||||||
this.color = this._resolveColor(color);
|
this.colour = this._resolveColour(colour);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
Loading…
Reference in a new issue