@@ -12,8 +12,12 @@ const formatColor = function (string) {
12
12
const processNestedColors = ( input ) => {
13
13
const regex = / ( \w + | # [ 0 - 9 A - F a - f ] { 3 , 6 } ) \{ ( [ ^ { } ] * ) \} / g;
14
14
let hasNestedMatch = false ;
15
+ if ( input === null || input === undefined ) {
16
+ return "Invalid input: " + input ;
17
+ }
15
18
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 } ` ;
17
21
}
18
22
const formattedString = input . replace ( regex , ( match , color , text ) => {
19
23
hasNestedMatch = true ;
@@ -45,7 +49,7 @@ function isHexColor(color) {
45
49
}
46
50
47
51
export default {
48
- logger : {
52
+ logger : {
49
53
debug : ( ...text ) => process . argv . includes ( "--debug" ) && console . log ( chalk . magentaBright . bold ( "[DEBUG]" ) , ...text . map ( x => formatColor ( x ) ) ) ,
50
54
info : ( ...text ) => console . log ( chalk . greenBright . bold ( "[INFO]" ) , ...text . map ( x => formatColor ( x ) ) ) ,
51
55
warn : ( ...text ) => console . log ( chalk . yellowBright . bold ( "[WARN]" ) , ...text . map ( x => formatColor ( x ) ) ) ,
@@ -61,7 +65,7 @@ export default {
61
65
setupMessage : setupMessage ,
62
66
setupSlashCommand : setupSlashCommand ,
63
67
setupModal : setupModal ,
64
-
68
+
65
69
createVariable : createVariable ,
66
70
botVariables : botVariables ,
67
71
userVariables : userVariables ,
0 commit comments