1 |
import BaseCommand from "./structures/BaseCommand"; |
2 |
import BaseEvent from "./structures/BaseEvent"; |
3 |
import { fill, green, red, timeProcess, yellow } from "./util"; |
4 |
|
5 |
let colLengths = [19, 33, 10]; |
6 |
let totalLength = colLengths.reduce((acc, val) => acc + val); |
7 |
|
8 |
export async function registrationStart() { |
9 |
if (process.env.ENV === 'prod' || !process.argv.includes('--verbose')) |
10 |
return; |
11 |
|
12 |
console.log(`+-----------------------------------------------------+`); |
13 |
console.log(`|Name |Time |Status |`); |
14 |
} |
15 |
|
16 |
export async function registered(command: BaseCommand | BaseEvent, startTime: number = 0, endTime: number = 0) { |
17 |
if (process.env.ENV === 'prod' || !process.argv.includes('--verbose')) |
18 |
return; |
19 |
|
20 |
console.log(`|-------------------+----------------------+----------|`); |
21 |
|
22 |
let name = command.getName(); |
23 |
let time: number = endTime - startTime; |
24 |
let timeString = time + 'ms'; |
25 |
|
26 |
if (time >= 100) { |
27 |
timeString = red(timeString); |
28 |
} |
29 |
else if (time >= 50) { |
30 |
timeString = yellow(timeString); |
31 |
} |
32 |
else { |
33 |
timeString = green(timeString); |
34 |
} |
35 |
|
36 |
let status = 'Success'; |
37 |
|
38 |
if (colLengths[0] > name.length) { |
39 |
name = fill(colLengths[0], name); |
40 |
} |
41 |
|
42 |
if (colLengths[1] > timeString.length) { |
43 |
timeString = fill(colLengths[1], timeString); |
44 |
} |
45 |
|
46 |
if (colLengths[2] > status.length) { |
47 |
status = fill(colLengths[2], status); |
48 |
} |
49 |
|
50 |
console.log(`|${green(name)}|${timeString}|${green(status)}|`); |
51 |
} |
52 |
|
53 |
export async function registrationEnd() { |
54 |
if (process.env.ENV === 'prod' || !process.argv.includes('--verbose')) |
55 |
return; |
56 |
|
57 |
console.log(`+-----------------------------------------------------+`); |
58 |
console.log(`\n`); |
59 |
} |