diff --git a/src/commands/developer/status.ts b/src/commands/developer/status.ts new file mode 100644 index 0000000..3b24d66 --- /dev/null +++ b/src/commands/developer/status.ts @@ -0,0 +1,92 @@ +import { ChannelType, EmbedBuilder, SlashCommandBuilder, time, TimestampStyles, UserFlags, User, version as djsVersion } from 'discord.js'; +import { Command } from '../../types/command'; +import ms from 'ms'; +import os from 'os'; +import config from '../../lib/config'; + +const command: Command = { + data: new SlashCommandBuilder() + .setName('status') + .setDescription('Get the bot status'), + category: 'Developer', + developerOnly: true, + async execute(interaction, client) { + // Fetch the user and application data + await client.user?.fetch(); + await client.application?.fetch(); + + // Function to get the size of the channels based on the type + const getChannelTypeSize = (type: ChannelType[]) => client.channels.cache.filter((channel) => type.includes(channel.type)).size; + + // Create an embed with the bot status information + const embed = new EmbedBuilder() + .setColor(config.colors.embed) + .setTitle(`๐Ÿค– ${client.user?.username} Status`) + .setDescription(client.application?.description || null) + .addFields( + { name: "๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ”ง Client", value: client.user?.tag ?? "", inline: true }, + { + name: "๐Ÿ“† Created", + value: `${time(Math.floor((client.user?.createdTimestamp || 0) / 1000), TimestampStyles.RelativeTime)}`, + inline: true, + }, + { + name: "โ˜‘ Verified", + value: client.user?.flags?.has(UserFlags.VerifiedBot) ? "Yes" : "No", + inline: true, + }, + { + name: "๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป Owner", + value: `${client.application?.owner instanceof User ? client.application.owner.username : 'Team'}`, + inline: true, + }, + { + name: "๐Ÿ–ฅ System", + value: os.type().replace("Windows_NT", "Windows").replace("Darwin", "macOS"), + inline: true, + }, + { name: "๐Ÿง  CPU Model", value: `${os.cpus()[0].model}`, inline: true }, + { + name: "๐Ÿ’พ Memory Usage", + value: `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(0)} MB`, + inline: true, + }, + { + name: "โฐ Up Since", + value: `${time(Math.floor((client?.readyTimestamp || 0) / 1000), TimestampStyles.RelativeTime)}`, + inline: true, + }, + { name: "โณ Uptime", value: client?.uptime ? ms(client?.uptime) : "-", inline: true }, + { name: "๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ”ง Node.js", value: process.version, inline: true }, + { name: "๐Ÿ›  Discord.js", value: djsVersion, inline: true }, + { name: "๐Ÿ“ Ping", value: `${client.ws.ping === -1 ? "-" : ms(client.ws.ping)}`, inline: true }, + { name: "๐Ÿคน๐Ÿปโ€โ™€๏ธ Commands", value: `${client.commands.size}`, inline: true }, + { name: "๐ŸŒ Servers", value: `${client.guilds.cache.size}`, inline: true }, + { + name: "๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Users", + value: `${client.guilds.cache.reduce((acc, guild) => acc + (guild.memberCount || 0), 0).toLocaleString()}`, + inline: true + }, + { + name: "๐Ÿ’ฌ Text Channels", + value: `${getChannelTypeSize([ChannelType.GuildText, ChannelType.GuildAnnouncement])}`, + inline: true, + }, + { + name: "๐ŸŽค Voice Channels", + value: `${getChannelTypeSize([ChannelType.GuildVoice, ChannelType.GuildStageVoice])}`, + inline: true, + }, + { + name: "๐Ÿงต Threads", + value: `${getChannelTypeSize([ChannelType.PublicThread, ChannelType.PrivateThread, ChannelType.AnnouncementThread])}`, + inline: true, + } + ); + + // Reply to the user with the bot status + return await interaction.reply({ embeds: [embed], ephemeral: true }); + }, +}; + +export default command;