1
- export const cmd = [ "ping" ] ;
2
- export const name = "ping" ;
3
- export const category = "main" ;
4
- export const description = "Balas dengan pong" ;
5
- export async function execute ( m , { client } ) {
6
- try {
7
- await client . sendMessage ( m . chat , { text : "Pong!" } ) ;
8
- } catch ( error ) {
9
- console . error ( "Error sending pong message:" , error ) ;
10
- }
11
- }
1
+ import os from "os" ;
2
+ import v8 from "v8" ;
3
+
4
+ const more = String . fromCharCode ( 8206 ) ;
5
+ const readmore = more . repeat ( 4001 ) ;
6
+
12
7
export default {
13
- cmd,
14
- name,
15
- category,
16
- description,
17
- execute,
18
- } ;
8
+ cmd : [ "ping" ] ,
9
+ name : "ping" ,
10
+ category : "main" ,
11
+ description : "Detail server & cek speed" ,
12
+ async execute ( m , { Func : func } ) {
13
+ const start = performance . now ( ) ;
14
+ await m . react ( "🏓" ) ;
15
+ const end = performance . now ( ) ;
16
+ const elapsed = end - start ;
17
+ const used = process . memoryUsage ( ) ;
18
+ const cpus = os . cpus ( ) . map ( ( cpu ) => {
19
+ cpu . total = Object . keys ( cpu . times ) . reduce (
20
+ ( last , type ) => last + cpu . times [ type ] ,
21
+ 0 ,
22
+ ) ;
23
+ return cpu ;
24
+ } ) ;
25
+ const cpu = cpus . reduce (
26
+ ( last , cpu , _ , { length } ) => {
27
+ last . total += cpu . total ;
28
+ last . speed += cpu . speed / length ;
29
+ last . times . user += cpu . times . user ;
30
+ last . times . nice += cpu . times . nice ;
31
+ last . times . sys += cpu . times . sys ;
32
+ last . times . idle += cpu . times . idle ;
33
+ last . times . irq += cpu . times . irq ;
34
+ return last ;
35
+ } ,
36
+ {
37
+ speed : 0 ,
38
+ total : 0 ,
39
+ times : {
40
+ user : 0 ,
41
+ nice : 0 ,
42
+ sys : 0 ,
43
+ idle : 0 ,
44
+ irq : 0 ,
45
+ } ,
46
+ } ,
47
+ ) ;
48
+ let heapStat = v8 . getHeapStatistics ( ) ;
49
+ const x = "`" ;
50
+
51
+ const resp = `bot response in \`${ ( elapsed / 1000 ) . toFixed ( 2 ) } seconds\`` ;
52
+
53
+ let teks = `${ resp }
54
+ - Uptime = _${ func . runtime ( process . uptime ( ) ) } _
55
+ - CPU Core = _${ cpus . length } _
56
+ - Platform = _${ os . platform ( ) } _
57
+ - Ram = _${ func . formatSize (
58
+ os . totalmem ( ) - os . freemem ( ) ,
59
+ ) } _ / _${ func . formatSize ( os . totalmem ( ) ) } _
60
+ ${ readmore }
61
+ ${ x } NODE MEMORY USAGE${ x }
62
+ ${ Object . keys ( used )
63
+ . map (
64
+ ( key , _ , arr ) =>
65
+ `*- ${ key . padEnd (
66
+ Math . max ( ...arr . map ( ( v ) => v . length ) ) ,
67
+ " " ,
68
+ ) } =* ${ func . formatSize ( used [ key ] ) } `,
69
+ )
70
+ . join ( "\n" ) }
71
+ *- Heap Executable f=* ${ func . formatSize ( heapStat ?. total_heap_size_executable ) }
72
+ *- Physical Size =* ${ func . formatSize ( heapStat ?. total_physical_size ) }
73
+ *- Available Size =* ${ func . formatSize ( heapStat ?. total_available_size ) }
74
+ *- Heap Limit =* ${ func . formatSize ( heapStat ?. heap_size_limit ) }
75
+ *- Malloced Memory =* ${ func . formatSize ( heapStat ?. malloced_memory ) }
76
+ *- Peak Malloced Memory =* ${ func . formatSize ( heapStat ?. peak_malloced_memory ) }
77
+ *- Does Zap Garbage =* ${ func . formatSize ( heapStat ?. does_zap_garbage ) }
78
+ *- Native Contexts =* ${ func . formatSize ( heapStat ?. number_of_native_contexts ) }
79
+ *- Detached Contexts =* ${ func . formatSize (
80
+ heapStat ?. number_of_detached_contexts ,
81
+ ) }
82
+ *- Total Global Handles =* ${ func . formatSize (
83
+ heapStat ?. total_global_handles_size ,
84
+ ) }
85
+ *- Used Global Handles =* ${ func . formatSize ( heapStat ?. used_global_handles_size ) }
86
+ ${
87
+ cpus [ 0 ]
88
+ ? `
89
+
90
+ *_Total CPU Usage_*
91
+ ${ cpus [ 0 ] . model . trim ( ) } (${ cpu . speed } MHZ)\n${ Object . keys ( cpu . times )
92
+ . map (
93
+ ( type ) =>
94
+ `*- ${ ( type + "*" ) . padEnd ( 6 ) } : ${ (
95
+ ( 100 * cpu . times [ type ] ) /
96
+ cpu . total
97
+ ) . toFixed ( 2 ) } %`,
98
+ )
99
+ . join ( "\n" ) }
100
+
101
+ *_CPU Core(s) Usage (${ cpus . length } Core CPU)_*
102
+ ${ cpus
103
+ . map (
104
+ ( cpu , i ) =>
105
+ `${ i + 1 } . ${ cpu . model . trim ( ) } (${ cpu . speed } MHZ)\n${ Object . keys (
106
+ cpu . times ,
107
+ )
108
+ . map (
109
+ ( type ) =>
110
+ `*- ${ ( type + "*" ) . padEnd ( 6 ) } : ${ (
111
+ ( 100 * cpu . times [ type ] ) /
112
+ cpu . total
113
+ ) . toFixed ( 2 ) } %`,
114
+ )
115
+ . join ( "\n" ) } `,
116
+ )
117
+ . join ( "\n\n" ) } `
118
+ : ""
119
+ }
120
+ ` . trim ( ) ;
121
+ m . reply ( teks ) ;
122
+ } ,
123
+ } ;
0 commit comments