1 |
import { CommandInteraction, GuildMember, Interaction, Message } from 'discord.js'; |
import { CommandInteraction, Message } from 'discord.js'; |
2 |
import BaseCommand from '../../utils/structures/BaseCommand'; |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
import DiscordClient from '../../client/Client'; |
import DiscordClient from '../../client/Client'; |
4 |
import CommandOptions from '../../types/CommandOptions'; |
import CommandOptions from '../../types/CommandOptions'; |
5 |
import InteractionOptions from '../../types/InteractionOptions'; |
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
import MessageEmbed from '../../client/MessageEmbed'; |
import MessageEmbed from '../../client/MessageEmbed'; |
7 |
import { fetchEmoji } from '../../utils/Emoji'; |
import { fetchEmoji } from '../../utils/Emoji'; |
8 |
|
import { formatDuration, intervalToDuration } from 'date-fns'; |
9 |
|
import os from 'os'; |
10 |
|
|
11 |
export default class SystemCommand extends BaseCommand { |
export default class SystemCommand extends BaseCommand { |
12 |
constructor() { |
constructor() { |
55 |
apiLatencyIcon = '🟡'; |
apiLatencyIcon = '🟡'; |
56 |
} |
} |
57 |
|
|
58 |
const memoryFree = Math.round(process.memoryUsage().heapUsed / 1024 / 1024 * 100) / 100; |
const memoryTotal = Math.round(os.totalmem() / 1024 / 1024); |
59 |
|
const memoryUsed = Math.round((os.totalmem() - os.freemem()) / 1024 / 1024); |
60 |
|
const memoryUsedByBot = Math.round(process.memoryUsage().heapUsed / 1024 / 1024); |
61 |
|
|
62 |
const msgoptions: any = { |
const msgoptions: any = { |
63 |
embeds: [ |
embeds: [ |
69 |
.setDescription((latencyIcon !== '🔴' ? (await fetchEmoji('check'))?.toString() + ' All systems operational' : ':x: Some systems are down/slow')) |
.setDescription((latencyIcon !== '🔴' ? (await fetchEmoji('check'))?.toString() + ' All systems operational' : ':x: Some systems are down/slow')) |
70 |
.addFields([ |
.addFields([ |
71 |
{ |
{ |
72 |
name: 'Type', |
name: 'Command Type', |
73 |
value: `${msg instanceof Message ? 'Legacy (Message-based)' : 'Slash Command'}` |
value: `${!options.isInteraction ? 'Legacy (Message-based)' : 'Slash Command'}` |
74 |
|
}, |
75 |
|
{ |
76 |
|
name: 'Uptime', |
77 |
|
value: `${formatDuration(intervalToDuration({ |
78 |
|
start: 0, |
79 |
|
end: process.uptime() * 1000 |
80 |
|
}))}` |
81 |
}, |
}, |
82 |
{ |
{ |
83 |
name: 'Latency', |
name: 'Latency', |
88 |
value: `${apiLatencyIcon} ${apiLatency}ms` |
value: `${apiLatencyIcon} ${apiLatency}ms` |
89 |
}, |
}, |
90 |
{ |
{ |
91 |
name: 'Available Memory', |
name: 'Memory Usage', |
92 |
value: `${memoryFree}MB / 1.0GB` |
value: `${memoryUsed}MB / ${memoryTotal}MB (${memoryUsedByBot}MB used by the bot)` |
93 |
}, |
}, |
94 |
{ |
{ |
95 |
name: 'System Platform', |
name: 'System Platform', |