From 644a377acd4be2ee0404b81ca4f4c5eaf0ba3265 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 3 Apr 2018 13:21:11 -0400 Subject: [PATCH 01/15] Add color utils --- utils/colors.js | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 utils/colors.js diff --git a/utils/colors.js b/utils/colors.js new file mode 100644 index 0000000..45fc43f --- /dev/null +++ b/utils/colors.js @@ -0,0 +1,80 @@ +const colors = { + WHITE: '\x0300', + BLACK: '\x0301', + NAVY: '\x0302', + GREEN: '\x0303', + RED: '\x0304', + BROWN: '\x0305', + MAROON: '\x0305', + PURPLE: '\x0306', + VIOLET: '\x0306', + ORANGE: '\x0307', + YELLOW: '\x0308', + LIGHTGREEN: '\x0309', + LIME: '\x0309', + TEAL: '\x0310', + BLUECYAN: '\x0310', + CYAN: '\x0311', + AQUA: '\x0311', + BLUE: '\x0312', + ROYAL: '\x0312', + LIGHTPURPLE: '\x0313', + PINK: '\x0313', + FUCHSIA: '\x0313', + GREY: '\x0314', + GRAY: '\x0314', + LIGHTGRAY: '\x0315', + LIGHTGREY: '\x0315', + SILVER: '\x0315', + + NORMAL: '\x0F', + UNDERLINE: '\x1F', + BOLD: '\x02', + ITALIC: '\x1D', + REVERSE: '\u202E' +}; + +const _rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'navy', 'violet']; + + +function rainbow(string) { + let i = 0; + let colored = ''; + + for (let character of string) { + if (i > (_rainbow.length - 1)) // We substract one because i starts at 0 and rainbow.length at 1 + i = 0; + + colored.concat(`${colors[_rainbow[i].toUpper()]}${character}`); + i += 1; + } + + return colored.concat('\x0F'); +} + +function background(string, bg) { + let c = string.indexOf('\x03') !== -1; + + if (c && bg !== null) { + return `${string.slice(0, 3)},${colors[bg]}${string.slice(3)}`; + } else if (!c && bg !== null) { + return `${colors.black},${colors[bg]}${string}\x0F`; + } else if (bg === null) { + return string; + } +} + +function stylize(string, style) { + if (style !== null) { + return `${colors[style.upper()]}${string}`; + } + + return string; +} + +module.export = { + colors, + rainbow, + background, + stylize +}; From dc3a9ab0a446db7239c602196a57c69a10137146 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 3 Apr 2018 13:22:09 -0400 Subject: [PATCH 02/15] Add implentation to the IRC wrappers --- wrappers.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/wrappers.js b/wrappers.js index 9b34408..a7fb1e4 100644 --- a/wrappers.js +++ b/wrappers.js @@ -1,5 +1,6 @@ const { range } = require('node-python-funcs'); const { chunks } = require('./utils/general'); +const colors = require('./utils/colors'); /** Class that provides methods for IRC commands */ class ConnectionWrapper { @@ -25,21 +26,25 @@ class ConnectionWrapper { * @func * @param {object} event - The event object created when parsing the incoming messages. * @param {string} message - The message you wish to reply with. + * @param {string} [background=null] + * @param {boolena} [rainbow=false] + * @param {string} [style=null] */ - reply(event, message) { - if (event.target === this.bot.nickname) { - this.privmsg(event.source.nick, message); - } else { - this.privmsg(event.target, message); - } + reply(event, message, background=null, rainbow=false, style=null) { + let isPRIVMSG = event.target === this.bot.nickname; + + this.privmsg(isPRIVMSG ? event.target : event.source.nick, message, background, rainbow, style); } /** * @func * @param {string} target - The user or channel you wish to send a PRIVMSG to. * @param {string} message - The message you wish to send. + * @param {string} [background=null] + * @param {boolena} [rainbow=false] + * @param {string} [style=null] */ - privmsg(target, message) { + privmsg(target, message, background=null, rainbow=false, style=null) { const channel = target.startsWith('#') ? target : this.bot.state.channels.keys()[0]; const db = this.bot.state.channels[channel].users[this.bot.nickname]; // The maximum length for messages is 512 bytes total including nick, ident & host @@ -48,6 +53,15 @@ class ConnectionWrapper { let msg = Buffer.from(message); for (let i of range(0, msg.byteLength, MSGLEN)) { + let myRe = /\${(\w+)}/g; + let myArray; + + while ((myArray = myRe.exec(msg)) !== null) { + msg.replace(myArray[0], colors.colors[myArray[1]]); + } + + if (rainbow) msg = rainbow(msg); + msg = colors.stylize(colors.background(msg, background), style); this.bot.send(`PRIVMSG ${target} :${msg.slice(i, i + MSGLEN).toString()}`); } } From f9d05514a6684cbe6e675ecb4dc4578c6ac66a7b Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 3 Apr 2018 13:23:51 -0400 Subject: [PATCH 03/15] Fix typo in JSDoc comments --- wrappers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers.js b/wrappers.js index a7fb1e4..5dcf25b 100644 --- a/wrappers.js +++ b/wrappers.js @@ -27,7 +27,7 @@ class ConnectionWrapper { * @param {object} event - The event object created when parsing the incoming messages. * @param {string} message - The message you wish to reply with. * @param {string} [background=null] - * @param {boolena} [rainbow=false] + * @param {boolean} [rainbow=false] * @param {string} [style=null] */ reply(event, message, background=null, rainbow=false, style=null) { @@ -41,7 +41,7 @@ class ConnectionWrapper { * @param {string} target - The user or channel you wish to send a PRIVMSG to. * @param {string} message - The message you wish to send. * @param {string} [background=null] - * @param {boolena} [rainbow=false] + * @param {boolean} [rainbow=false] * @param {string} [style=null] */ privmsg(target, message, background=null, rainbow=false, style=null) { From b07f640ba1b777be09671a758096ee79fbf5a3cd Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 3 Apr 2018 13:30:43 -0400 Subject: [PATCH 04/15] Move logic for styling a message to it's own function --- utils/colors.js | 23 ++++++++++++++++++----- wrappers.js | 10 +--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/utils/colors.js b/utils/colors.js index 45fc43f..f09a1ab 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -37,7 +37,7 @@ const colors = { const _rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'navy', 'violet']; -function rainbow(string) { +function make_rainbow(string) { let i = 0; let colored = ''; @@ -52,7 +52,7 @@ function rainbow(string) { return colored.concat('\x0F'); } -function background(string, bg) { +function add_background(string, bg) { let c = string.indexOf('\x03') !== -1; if (c && bg !== null) { @@ -72,9 +72,22 @@ function stylize(string, style) { return string; } +function addStyling(msg, background, rainbow, style) { + let myRe = /\${(\w+)}/g; + let myArray; + + while ((myArray = myRe.exec(msg)) !== null) { + msg.replace(myArray[0], colors.colors[myArray[1]]); + } + + if (rainbow) msg = make_rainbow(msg); + msg = stylize(add_background(msg, background), style); +} + module.export = { colors, - rainbow, - background, - stylize + make_rainbow, + add_background, + stylize, + addStyling }; diff --git a/wrappers.js b/wrappers.js index 5dcf25b..d5324fd 100644 --- a/wrappers.js +++ b/wrappers.js @@ -53,15 +53,7 @@ class ConnectionWrapper { let msg = Buffer.from(message); for (let i of range(0, msg.byteLength, MSGLEN)) { - let myRe = /\${(\w+)}/g; - let myArray; - - while ((myArray = myRe.exec(msg)) !== null) { - msg.replace(myArray[0], colors.colors[myArray[1]]); - } - - if (rainbow) msg = rainbow(msg); - msg = colors.stylize(colors.background(msg, background), style); + msg = colors.addStyling(msg, background, rainbow, style); this.bot.send(`PRIVMSG ${target} :${msg.slice(i, i + MSGLEN).toString()}`); } } From bbe759834221e4817f2666a65a0f56dac937e6c4 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 3 Apr 2018 21:15:04 -0400 Subject: [PATCH 05/15] Fix some problems related to undefined variables --- utils/colors.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/colors.js b/utils/colors.js index f09a1ab..9e984be 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -77,14 +77,15 @@ function addStyling(msg, background, rainbow, style) { let myArray; while ((myArray = myRe.exec(msg)) !== null) { - msg.replace(myArray[0], colors.colors[myArray[1]]); + msg.replace(myArray[0], colors[myArray[1]]); } if (rainbow) msg = make_rainbow(msg); - msg = stylize(add_background(msg, background), style); + + return stylize(add_background(msg, background), style); } -module.export = { +module.exports = { colors, make_rainbow, add_background, From cdde1a53f35178685dd6f36c5d4a23171754cbd4 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 3 Apr 2018 21:16:04 -0400 Subject: [PATCH 06/15] Colours should be included in the total message length --- wrappers.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wrappers.js b/wrappers.js index d5324fd..9884a6b 100644 --- a/wrappers.js +++ b/wrappers.js @@ -50,10 +50,9 @@ class ConnectionWrapper { // The maximum length for messages is 512 bytes total including nick, ident & host const MAXLEN = 512 - 2 - Buffer.byteLength(db.hostmask); // 1 for beggining double colon const MSGLEN = MAXLEN - Buffer.byteLength(`PRIVMSG ${target} :\r\n`); - let msg = Buffer.from(message); + let msg = Buffer.from(colors.addStyling(message, background, rainbow, style)); for (let i of range(0, msg.byteLength, MSGLEN)) { - msg = colors.addStyling(msg, background, rainbow, style); this.bot.send(`PRIVMSG ${target} :${msg.slice(i, i + MSGLEN).toString()}`); } } From fe3dd5e3b19a265d4c4b8cfa59baa639a1219ca2 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 3 Apr 2018 21:57:50 -0400 Subject: [PATCH 07/15] Stylistic improvements to color utils Add JSDoc comments (placeholders mostly for now) Rename string variables to msg to better reflect their usage --- utils/colors.js | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/utils/colors.js b/utils/colors.js index 9e984be..0da91f3 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -36,12 +36,16 @@ const colors = { const _rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'navy', 'violet']; - -function make_rainbow(string) { +/** +* Colors a message with rainbow colors +* @param {string} msg - The message you want to add rainbow colors too +* @return {string} - Returns your message returned with rainbow coloring +*/ +function make_rainbow(msg) { let i = 0; let colored = ''; - for (let character of string) { + for (let character of msg) { if (i > (_rainbow.length - 1)) // We substract one because i starts at 0 and rainbow.length at 1 i = 0; @@ -52,24 +56,36 @@ function make_rainbow(string) { return colored.concat('\x0F'); } -function add_background(string, bg) { - let c = string.indexOf('\x03') !== -1; +/** +* Colors a message with rainbow colors +* @param {string} msg - The message you want to add rainbow colors too +* @param {string} bg - The message you want to add rainbow colors too +* @return {string} - Returns your message returned with rainbow coloring +*/ +function add_background(msg, bg) { + let c = msg.indexOf('\x03') !== -1; if (c && bg !== null) { - return `${string.slice(0, 3)},${colors[bg]}${string.slice(3)}`; + return `${msg.slice(0, 3)},${colors[bg]}${msg.slice(3)}`; } else if (!c && bg !== null) { - return `${colors.black},${colors[bg]}${string}\x0F`; + return `${colors.black},${colors[bg]}${msg}\x0F`; } else if (bg === null) { - return string; + return msg; } } -function stylize(string, style) { +/** +* Colors a message with rainbow colors +* @param {string} msg - The message you want to add rainbow colors too +* @param {string} style - The message you want to add rainbow colors too +* @return {string} - Returns your message returned with rainbow coloring +*/ +function stylize(msg, style) { if (style !== null) { - return `${colors[style.upper()]}${string}`; + return `${colors[style.upper()]}${msg}`; } - return string; + return msg; } function addStyling(msg, background, rainbow, style) { From d26c4cb20973bb27681cfe02873d6414900c10b8 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 3 Apr 2018 21:58:52 -0400 Subject: [PATCH 08/15] Fix irc.reply() Switched parameters around and ended up re-adding the reply infinite loop and replying in PRIVMSG instead of in the channel (if the message was sent in a channel) --- wrappers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers.js b/wrappers.js index 9884a6b..d29694e 100644 --- a/wrappers.js +++ b/wrappers.js @@ -33,7 +33,7 @@ class ConnectionWrapper { reply(event, message, background=null, rainbow=false, style=null) { let isPRIVMSG = event.target === this.bot.nickname; - this.privmsg(isPRIVMSG ? event.target : event.source.nick, message, background, rainbow, style); + this.privmsg(isPRIVMSG ? event.source.nick : event.target, message, background, rainbow, style); } /** From e07e51ffaaff8d5208b6929ca3eece05b2cc6c7d Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Mon, 9 Apr 2018 14:54:22 -0400 Subject: [PATCH 09/15] Fix: Use the right function name for upper case --- utils/colors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/colors.js b/utils/colors.js index 0da91f3..f3b8456 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -49,7 +49,7 @@ function make_rainbow(msg) { if (i > (_rainbow.length - 1)) // We substract one because i starts at 0 and rainbow.length at 1 i = 0; - colored.concat(`${colors[_rainbow[i].toUpper()]}${character}`); + colored.concat(`${colors[_rainbow[i].toUpperCase()]}${character}`); i += 1; } @@ -82,7 +82,7 @@ function add_background(msg, bg) { */ function stylize(msg, style) { if (style !== null) { - return `${colors[style.upper()]}${msg}`; + return `${colors[style.toUpperCase()]}${msg}`; } return msg; From d1351a9e5ac709e788e856ebba0afbcd27a3aa7e Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Mon, 9 Apr 2018 15:56:30 -0400 Subject: [PATCH 10/15] Fix setting backgrounds - Strip the first byte (0x3) to get the color code - Color names are in upper case, so transform the argument for that --- utils/colors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/colors.js b/utils/colors.js index f3b8456..ec81e80 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -66,9 +66,9 @@ function add_background(msg, bg) { let c = msg.indexOf('\x03') !== -1; if (c && bg !== null) { - return `${msg.slice(0, 3)},${colors[bg]}${msg.slice(3)}`; + return `${msg.slice(0, 3)},${colors[bg.toUpperCase()].slice(1)}${msg.slice(3)}`; } else if (!c && bg !== null) { - return `${colors.black},${colors[bg]}${msg}\x0F`; + return `${colors.BLACK},${colors[bg.toUpperCase()].slice(1)}${msg}\x0F`; } else if (bg === null) { return msg; } From dfd1b200bd899b3f89aaa14e8fe78d6e6d7c642e Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 10 Apr 2018 20:35:15 -0400 Subject: [PATCH 11/15] Fix rainbow When using an empty string, String.prototype.concat doesn't seem to work, but using += does --- utils/colors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/colors.js b/utils/colors.js index ec81e80..010785a 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -49,7 +49,7 @@ function make_rainbow(msg) { if (i > (_rainbow.length - 1)) // We substract one because i starts at 0 and rainbow.length at 1 i = 0; - colored.concat(`${colors[_rainbow[i].toUpperCase()]}${character}`); + colored += `${colors[_rainbow[i].toUpperCase()]}${character}`; i += 1; } From ecdf00c469c5d87884cfbb8765691c8373a5a2c0 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Fri, 4 May 2018 16:05:30 -0400 Subject: [PATCH 12/15] Add a proof of concept for a new color class --- utils/colors.js | 226 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 217 insertions(+), 9 deletions(-) diff --git a/utils/colors.js b/utils/colors.js index 010785a..c9a19a4 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -37,10 +37,223 @@ const colors = { const _rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'navy', 'violet']; /** -* Colors a message with rainbow colors -* @param {string} msg - The message you want to add rainbow colors too -* @return {string} - Returns your message returned with rainbow coloring +* Colors a message */ +class Color extends String { + /** + * @param {string} message - The message you want to add rainbow colors too + */ + constructor(message) { + super(message); + } + + white() { + super(`${colors.WHITE}${this}${colors.NORMAL}`); + + return this; + } + + black() { + super(`${colors.BLACK}${this}${colors.NORMAL}`); + + return this; + } + + navy() { + super(`${colors.NAVY}${this}${colors.NORMAL}`); + + return this; + } + + green() { + super(`${colors.GREEN}${this}${colors.NORMAL}`); + + return this; + } + + red() { + super(`${colors.RED}${this}${colors.NORMAL}`); + + return this; + } + + brown() { + super(`${colors.BROWN}${this}${colors.NORMAL}`); + + return this; + } + + maroon() { + super(`${colors.MAROON}${this}${colors.NORMAL}`); + + return this; + } + + purple() { + super(`${colors.PURPLE}${this}${colors.NORMAL}`); + + return this; + } + + violet() { + super(`${colors.VIOLET}${this}${colors.NORMAL}`); + + return this; + } + + orange() { + super(`${colors.ORANGE}${this}${colors.NORMAL}`); + + return this; + } + + yellow() { + super(`${colors.YELLOW}${this}${colors.NORMAL}`); + + return this; + } + + lightgreen() { + super(`${colors.LIGHTGREEN}${this}${colors.NORMAL}`); + + return this; + } + + lime() { + super(`${colors.LIME}${this}${colors.NORMAL}`); + + return this; + } + + teal() { + super(`${colors.TEAL}${this}${colors.NORMAL}`); + + return this; + } + + bluecyan() { + super(`${colors.BLUECYAN}${this}${colors.NORMAL}`); + + return this; + } + + cyan() { + super(`${colors.CYAN}${this}${colors.NORMAL}`); + + return this; + } + + aqua() { + super(`${colors.AQUA}${this}${colors.NORMAL}`); + + return this; + } + + blue() { + super(`${colors.BLUE}${this}${colors.NORMAL}`); + + return this; + } + + royal() { + super(`${colors.ROYAL}${this}${colors.NORMAL}`); + + return this; + } + + lightpurple() { + super(`${colors.LIGHTPURPLE}${this}${colors.NORMAL}`); + + return this; + } + + pink() { + super(`${colors.PINK}${this}${colors.NORMAL}`); + + return this; + } + + fuchsia() { + super(`${colors.FUCHSIA}${this}${colors.NORMAL}`); + + return this; + } + + grey() { + super(`${colors.GREY}${this}${colors.NORMAL}`); + + return this; + } + + gray() { + super(`${colors.GRAY}${this}${colors.NORMAL}`); + + return this; + } + + lightgray() { + super(`${colors.LIGHTGRAY}${this}${colors.NORMAL}`); + + return this; + } + + lightgrey() { + super(`${colors.LIGHTGREY}${this}${colors.NORMAL}`); + + return this; + } + + silver() { + super(`${colors.SILVER}${this}${colors.NORMAL}`); + + return this; + } + + + bold() { + super(`${colors.BOLD}${this}${colors.NORMAL}`); + + return this; + } + + italic() { + super(`${colors.ITALIC}${this}${colors.NORMAL}`); + + return this; + } + + underline() { + super(`${colors.UNDERLINE}${this}${colors.NORMAL}`); + + return this; + } + + reverse() { + super(`${colors.ITALIC}${this}${colors.NORMAL}`); + + return this; + } + + /** + * Colors a message with rainbow colors + * @return {string} - Returns your message returned with rainbow coloring + */ + rainbow() { + let i = 0; + let colored = ''; + + for (let character of this) { + if (i > (_rainbow.length - 1)) // We substract one because i starts at 0 and rainbow.length at 1 + i = 0; + + colored += `${colors[_rainbow[i].toUpperCase()]}${character}`; + i += 1; + } + + return colored.concat('\x0F'); + } +} + function make_rainbow(msg) { let i = 0; let colored = ''; @@ -74,12 +287,7 @@ function add_background(msg, bg) { } } -/** -* Colors a message with rainbow colors -* @param {string} msg - The message you want to add rainbow colors too -* @param {string} style - The message you want to add rainbow colors too -* @return {string} - Returns your message returned with rainbow coloring -*/ + function stylize(msg, style) { if (style !== null) { return `${colors[style.toUpperCase()]}${msg}`; From 45421e5422b14feb1c2184f4a06532f3962ab094 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Fri, 4 May 2018 16:33:14 -0400 Subject: [PATCH 13/15] Remove methods not needed anymore --- utils/colors.js | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/utils/colors.js b/utils/colors.js index c9a19a4..1798f1e 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -254,21 +254,6 @@ class Color extends String { } } -function make_rainbow(msg) { - let i = 0; - let colored = ''; - - for (let character of msg) { - if (i > (_rainbow.length - 1)) // We substract one because i starts at 0 and rainbow.length at 1 - i = 0; - - colored += `${colors[_rainbow[i].toUpperCase()]}${character}`; - i += 1; - } - - return colored.concat('\x0F'); -} - /** * Colors a message with rainbow colors * @param {string} msg - The message you want to add rainbow colors too @@ -288,14 +273,6 @@ function add_background(msg, bg) { } -function stylize(msg, style) { - if (style !== null) { - return `${colors[style.toUpperCase()]}${msg}`; - } - - return msg; -} - function addStyling(msg, background, rainbow, style) { let myRe = /\${(\w+)}/g; let myArray; @@ -306,13 +283,11 @@ function addStyling(msg, background, rainbow, style) { if (rainbow) msg = make_rainbow(msg); - return stylize(add_background(msg, background), style); + return ((...args)=>{})(add_background(msg, background), style); } module.exports = { colors, - make_rainbow, add_background, - stylize, addStyling }; From e50870416a3c0d850c1ff1bcbe8f9e49b2d4b708 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Wed, 9 May 2018 11:43:48 -0400 Subject: [PATCH 14/15] Actually make class work --- utils/colors.js | 127 +++++++++++++----------------------------------- 1 file changed, 33 insertions(+), 94 deletions(-) diff --git a/utils/colors.js b/utils/colors.js index 1798f1e..07e7b56 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -48,190 +48,130 @@ class Color extends String { } white() { - super(`${colors.WHITE}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.WHITE}${this}${colors.NORMAL}`); } black() { - super(`${colors.BLACK}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.BLACK}${this}${colors.NORMAL}`); } navy() { - super(`${colors.NAVY}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.NAVY}${this}${colors.NORMAL}`); } green() { - super(`${colors.GREEN}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.GREEN}${this}${colors.NORMAL}`); } red() { - super(`${colors.RED}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.RED}${this}${colors.NORMAL}`); } brown() { - super(`${colors.BROWN}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.BROWN}${this}${colors.NORMAL}`); } maroon() { - super(`${colors.MAROON}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.MAROON}${this}${colors.NORMAL}`); } purple() { - super(`${colors.PURPLE}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.PURPLE}${this}${colors.NORMAL}`); } violet() { - super(`${colors.VIOLET}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.VIOLET}${this}${colors.NORMAL}`); } orange() { - super(`${colors.ORANGE}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.ORANGE}${this}${colors.NORMAL}`); } yellow() { - super(`${colors.YELLOW}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.YELLOW}${this}${colors.NORMAL}`); } lightgreen() { - super(`${colors.LIGHTGREEN}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.LIGHTGREEN}${this}${colors.NORMAL}`); } lime() { - super(`${colors.LIME}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.LIME}${this}${colors.NORMAL}`); } teal() { - super(`${colors.TEAL}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.TEAL}${this}${colors.NORMAL}`); } bluecyan() { - super(`${colors.BLUECYAN}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.BLUECYAN}${this}${colors.NORMAL}`); } cyan() { - super(`${colors.CYAN}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.CYAN}${this}${colors.NORMAL}`); } aqua() { - super(`${colors.AQUA}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.AQUA}${this}${colors.NORMAL}`); } blue() { - super(`${colors.BLUE}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.BLUE}${this}${colors.NORMAL}`); } royal() { - super(`${colors.ROYAL}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.ROYAL}${this}${colors.NORMAL}`); } lightpurple() { - super(`${colors.LIGHTPURPLE}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.LIGHTPURPLE}${this}${colors.NORMAL}`); } pink() { - super(`${colors.PINK}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.PINK}${this}${colors.NORMAL}`); } fuchsia() { - super(`${colors.FUCHSIA}${this}${colors.NORMAL}`); + return new Color(`${colors.FUCHSIA}${this}${colors.NORMAL}`); return this; } grey() { - super(`${colors.GREY}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.GREY}${this}${colors.NORMAL}`); } gray() { - super(`${colors.GRAY}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.GRAY}${this}${colors.NORMAL}`); } lightgray() { - super(`${colors.LIGHTGRAY}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.LIGHTGRAY}${this}${colors.NORMAL}`); } lightgrey() { - super(`${colors.LIGHTGREY}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.LIGHTGREY}${this}${colors.NORMAL}`); } silver() { - super(`${colors.SILVER}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.SILVER}${this}${colors.NORMAL}`); } bold() { - super(`${colors.BOLD}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.BOLD}${this}${colors.NORMAL}`); } italic() { - super(`${colors.ITALIC}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.ITALIC}${this}${colors.NORMAL}`); } underline() { - super(`${colors.UNDERLINE}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.UNDERLINE}${this}${colors.NORMAL}`); } reverse() { - super(`${colors.ITALIC}${this}${colors.NORMAL}`); - - return this; + return new Color(`${colors.ITALIC}${this}${colors.NORMAL}`); } /** @@ -250,7 +190,7 @@ class Color extends String { i += 1; } - return colored.concat('\x0F'); + return new Color(colored.concat('\x0F')); } } @@ -281,12 +221,11 @@ function addStyling(msg, background, rainbow, style) { msg.replace(myArray[0], colors[myArray[1]]); } - if (rainbow) msg = make_rainbow(msg); - return ((...args)=>{})(add_background(msg, background), style); } module.exports = { + Color, colors, add_background, addStyling From 25aed04eef10e856c73dcb2c296cba1467fa8cc0 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Wed, 9 May 2018 12:00:04 -0400 Subject: [PATCH 15/15] Fix a double return --- utils/colors.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/colors.js b/utils/colors.js index 07e7b56..e4d7c0d 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -133,8 +133,6 @@ class Color extends String { fuchsia() { return new Color(`${colors.FUCHSIA}${this}${colors.NORMAL}`); - - return this; } grey() {