11import { ChatInputCommandInteraction , EmbedBuilder , SlashCommandBuilder } from 'discord.js' ;
22import { connectedListDocument } from '../../Utils/typings/types' ;
3+ import { stripIndents } from 'common-tags' ;
34import utils from '../../Utils/functions/utils' ;
5+ import os from 'os' ;
46
57export default {
68 data : new SlashCommandBuilder ( )
79 . setName ( 'stats' )
810 . setDescription ( 'Shows the bot\'s statistics' ) ,
911 async execute ( interaction : ChatInputCommandInteraction ) {
1012 const uptime = utils . toHuman ( interaction . client ?. uptime as number ) ;
13+ const osUptime = utils . toHuman ( os . uptime ( ) * 1000 ) ;
1114 const database = utils . getDb ( ) ;
1215 const connectedList = database ?. collection ( 'connectedList' ) ;
1316 const count = await connectedList ?. countDocuments ( ) ;
1417 const allConnected = await connectedList ?. find ( { } ) . toArray ( ) ;
1518
19+ const docsLink = 'https://discord-chatbot.gitbook.io/docs' ;
20+ const inviteLink = 'https://discord.com/api/oauth2/authorize?client_id=769921109209907241&permissions=154820537425&scope=bot%20applications.commands' ;
21+ const supportServer = 'https://discord.gg/6bhXQynAPs' ;
22+
1623 let connectedMembers = 0 ;
1724 for ( const guildEntry of allConnected as connectedListDocument [ ] ) {
1825 let guild ;
@@ -25,65 +32,38 @@ export default {
2532 connectedMembers = connectedMembers + guild . memberCount ;
2633 }
2734
28-
2935 const embed = new EmbedBuilder ( )
3036 . setAuthor ( { name : `${ interaction . client . user ?. username } Statistics` , iconURL : interaction . client . user ?. avatarURL ( ) as string } )
31- . setColor ( utils . colors ( ) )
37+ . setColor ( utils . colors ( 'chatbot' ) )
38+ . setDescription ( `[Invite](${ inviteLink } ) • [Support](${ supportServer } ) • [Docs](${ docsLink } )` )
3239 . addFields ( [
3340 {
34- name : 'Uptime' ,
35- value : uptime ,
36- inline : true ,
37- } ,
38- {
39- name : 'Memory Usage' ,
40- value : `${ Math . round ( process . memoryUsage ( ) . heapUsed / 1024 / 1024 ) } MB / 1 GB` ,
41- inline : true ,
42- } ,
43- {
44- name : 'Ping' ,
45- value : `${ interaction . client . ws . ping } ms` ,
46- inline : true ,
47- } ,
48- {
49- name : 'Guilds' ,
50- value : `${ interaction . client . guilds . cache . size } ` ,
51- inline : true ,
52- } ,
53- {
54- name : 'Users' ,
55- value : `${ interaction . client . guilds . cache . reduce ( ( acc , guild ) => acc + guild . memberCount , 0 ) } ` ,
56- inline : true ,
57- } ,
58- {
59- name : 'Commands' ,
60- value : `${ interaction . client . commands . size } ` ,
61- inline : true ,
62- } ,
63- {
64- name : 'Bot Version' ,
65- value : `v${ interaction . client . version } ` ,
66- inline : true ,
67- } ,
68- {
69- name : 'Discord.JS' ,
70- value : `v${ require ( 'discord.js/package.json' ) . version } ` ,
71- inline : true ,
72- } ,
73- {
74- name : 'Node.JS' ,
75- value : `${ process . version } ` ,
76- inline : true ,
41+ name : 'System' ,
42+ value : stripIndents `\`\`\`elm
43+ CPU: ${ os . cpus ( ) [ 0 ] . model }
44+ Memory: ${ Math . round ( process . memoryUsage ( ) . heapUsed / 1024 / 1024 ) } MB / 1.75 GB
45+ Uptime: ${ osUptime }
46+ Discord.JS: ${ require ( 'discord.js/package.json' ) . version }
47+ Node.JS: ${ process . version }
48+ \`\`\`` ,
7749 } ,
7850 {
79- name : 'Connected Servers' ,
80- value : String ( count ) ,
81- inline : true ,
51+ name : 'Bot' ,
52+ value : stripIndents `\`\`\`elm
53+ Ping: ${ interaction . client . ws . ping } ms
54+ Uptime: ${ uptime }
55+ Servers: ${ interaction . client . guilds . cache . size }
56+ Users: ${ interaction . client . guilds . cache . reduce ( ( acc , guild ) => acc + guild . memberCount , 0 ) }
57+ Commands: ${ interaction . client . commands . size }
58+ Bot Version: v${ interaction . client . version }
59+ \`\`\`` ,
8260 } ,
8361 {
84- name : 'Connected Members' ,
85- value : String ( connectedMembers ) ,
86- inline : true ,
62+ name : 'Chat Network' ,
63+ value : stripIndents `\`\`\`elm
64+ Servers: ${ count }
65+ Members: ${ connectedMembers }
66+ \`\`\`` ,
8767 } ,
8868 ] ) ;
8969 await interaction . reply ( { embeds : [ embed ] } ) ;
0 commit comments