Skip to content

Commit 8a0a914

Browse files
committed
Fixed issue with BryanBot Logging and Objects
1 parent 6d10782 commit 8a0a914

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Modules/Utils.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ const formatColor = function (string) {
1212
const processNestedColors = (input) => {
1313
const regex = /(\w+|#[0-9A-Fa-f]{3,6})\{([^{}]*)\}/g;
1414
let hasNestedMatch = false;
15+
if (input === null || input === undefined) {
16+
return "Invalid input: " + input;
17+
}
1518
if (typeof input !== "string") {
16-
throw new Error(`Expected a string, but received: ${typeof input}`);
19+
if (typeof input === "object") input = JSON.stringify(input, "", 2);
20+
else return `Invalid input type: expected string, received ${typeof input}`;
1721
}
1822
const formattedString = input.replace(regex, (match, color, text) => {
1923
hasNestedMatch = true;
@@ -45,7 +49,7 @@ function isHexColor(color) {
4549
}
4650

4751
export default {
48-
logger: {
52+
logger: {
4953
debug: (...text) => process.argv.includes("--debug") && console.log(chalk.magentaBright.bold("[DEBUG]"), ...text.map(x => formatColor(x))),
5054
info: (...text) => console.log(chalk.greenBright.bold("[INFO]"), ...text.map(x => formatColor(x))),
5155
warn: (...text) => console.log(chalk.yellowBright.bold("[WARN]"), ...text.map(x => formatColor(x))),
@@ -61,7 +65,7 @@ export default {
6165
setupMessage: setupMessage,
6266
setupSlashCommand: setupSlashCommand,
6367
setupModal: setupModal,
64-
68+
6569
createVariable: createVariable,
6670
botVariables: botVariables,
6771
userVariables: userVariables,

0 commit comments

Comments
 (0)