Compare commits
No commits in common. "5138ddd8add598c870f791fad6d34a0d6ff1035a" and "c980594974c7b7eb077b6726b65516c54d48c6e0" have entirely different histories.
5138ddd8ad
...
c980594974
3 changed files with 1 additions and 56 deletions
|
@ -1,4 +1,5 @@
|
||||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||||
|
import process from 'node:process';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
||||||
import { MessageEmbed, version } from 'discord.js';
|
|
||||||
import os from 'node:os';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName('stats')
|
|
||||||
.setDescription('Show some stats about the bot'),
|
|
||||||
async execute(interaction) {
|
|
||||||
const client = interaction.client;
|
|
||||||
const uptime = process.uptime();
|
|
||||||
const date = new Date(uptime * 1000);
|
|
||||||
const days = date.getUTCDate() - 1,
|
|
||||||
hours = date.getUTCHours(),
|
|
||||||
minutes = date.getUTCMinutes(),
|
|
||||||
seconds = date.getUTCSeconds();
|
|
||||||
|
|
||||||
|
|
||||||
const segments = [];
|
|
||||||
|
|
||||||
// Format the uptime string.
|
|
||||||
if (days > 0) segments.push(days + ' day' + ((days == 1) ? '' : 's'));
|
|
||||||
if (hours > 0) segments.push(hours + ' hour' + ((hours == 1) ? '' : 's'));
|
|
||||||
if (minutes > 0) segments.push(minutes + ' minute' + ((minutes == 1) ? '' : 's'));
|
|
||||||
if (seconds > 0) segments.push(seconds + ' second' + ((seconds == 1) ? '' : 's'));
|
|
||||||
const dateString = segments.join(', ');
|
|
||||||
|
|
||||||
const bytesToSize = (bytes) => {
|
|
||||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
||||||
if (bytes == 0) return '0 Byte';
|
|
||||||
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
|
|
||||||
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
|
|
||||||
};
|
|
||||||
|
|
||||||
const statsEmbed = new MessageEmbed()
|
|
||||||
.setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY')
|
|
||||||
.setTitle('Bot stats')
|
|
||||||
.setAuthor({ name: client.user.tag, iconURL: client.user.displayAvatarURL(), url: 'https://libtar.de' })
|
|
||||||
.addField('Servers', client.guilds.cache.size.toString(), true)
|
|
||||||
.addField('Channels', client.channels.cache.size.toString(), true)
|
|
||||||
.addField('Users', client.users.cache.size.toString(), true)
|
|
||||||
.addField('Ram usage', `${bytesToSize(process.memoryUsage().heapUsed)}/${bytesToSize(os.totalmem)}`, true)
|
|
||||||
.addField('CPU', `${os.cpus()[0].model} (${os.cpus().length} core)`, true)
|
|
||||||
.addField('OS', `${os.platform()} ${os.release()}`, true)
|
|
||||||
.addField('Nodejs version', process.version, true)
|
|
||||||
.addField('Discord.js version', version, true)
|
|
||||||
.addField('Uptime', dateString, true)
|
|
||||||
.setTimestamp();
|
|
||||||
|
|
||||||
return interaction.reply({ embeds: [statsEmbed] });
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -81,10 +81,6 @@ const commands = [
|
||||||
new SlashCommandBuilder()
|
new SlashCommandBuilder()
|
||||||
.setName('about')
|
.setName('about')
|
||||||
.setDescription('About me (The bot)'),
|
.setDescription('About me (The bot)'),
|
||||||
|
|
||||||
new SlashCommandBuilder()
|
|
||||||
.setName('stats')
|
|
||||||
.setDescription('Show some stats about the bot'),
|
|
||||||
]
|
]
|
||||||
.map(command => command.toJSON());
|
.map(command => command.toJSON());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue