-
Notifications
You must be signed in to change notification settings - Fork 0
/
BDJSLog.ts
95 lines (87 loc) · 2.94 KB
/
BDJSLog.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { Data } from '../structures/Data'
import clc from 'cli-color'
type ErrorTypes = 'client' | 'command' | 'custom' | 'disallowed' | 'internal' | 'invalid' | 'required'
export class BDJSLog extends Error {
name = ''
message = ''
constructor(d: Data, type: ErrorTypes, ...args: string[] | undefined[]) {
let message: string
switch (type) {
case 'client':
message = `🤖 ${clc.blue('BDJS') + ':' + clc.blue('CLIENT')} | ${args.join(' ')}`
break
case 'custom':
message = `❌ ${clc.blue('BDJS') + ':' + clc.red('ERROR')} | ${args.join(' ')}`
break
case 'command':
message = `ℹ ${clc.blue('BDJS') + ':' + clc.magenta('COMMAND')} | ${args[0]} at ${args[1]}`
break
case 'disallowed':
message = `❌ ${clc.blue('BDJS') + ':' + clc.red('DISALLOWED')} | "${args[0]}" is only allowed in ${args[1]}`
break
case 'internal':
message = `⚠️ ${clc.blue('BDJS') + ':' + clc.yellowBright('INTERNAL')} | ${args.join(' ')}`
break
case 'invalid':
message = `❌ ${clc.blue('BDJS') + ':' + clc.red('ERROR')} | Invalid "${args[0]}" in ${args[1]}`
break
case 'required':
message = `❌ ${clc.blue('BDJS') + ':' + clc.red('ERROR')} | "${args[0]}" is required in ${args[1]}`
break
}
super(message)
this.message = message.split('|').map(x => x.trim())[1]
}
/**
* BDJSLog a colored error message into the console.
* @param message - The error message.
* @returns {void}
*/
static error(message: string) {
console.log(
'❌',
`${clc.blue('BDJS') + ':' + clc.red('ERROR')}`,
'|',
clc.magentaBright(message)
)
}
/**
* BDJSLog a colored information message into the console.
* @param message - The information message.
* @returns {void}
*/
static info(message: string) {
console.log(
'ℹ',
`${clc.blue('BDJS') + ':' + clc.cyan('INFO')}`,
'|',
clc.green(message)
)
}
/**
* BDJSLog a colored warning message into the console.
* @param message - The warning message.
* @returns {void}
*/
static warn(message: string) {
console.log(
'⚠️ ',
`${clc.blue('BDJS') + ':' + clc.yellowBright('WARN')}`,
'|',
clc.yellow(message)
)
}
/**
* BDJSLog a colored debug message into the console.
* @param message - The debug message.
* @returns {void}
*/
static debug(message: string) {
console.log(
'🐛',
`${clc.blue('BDJS') + ':' + clc.cyan('DEBUG')}`,
'|',
clc.blue(message)
)
}
}