mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-12-28 08:55:38 -05:00
Squash two embeds together.
This commit is contained in:
parent
39d28a309e
commit
9d01b6954a
@ -1,11 +1,27 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import {version} from 'typescript';
|
||||||
import si from 'systeminformation';
|
import si from 'systeminformation';
|
||||||
|
import TClient from 'src/client';
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import { version } from 'typescript';
|
|
||||||
import { VERSION } from 'ts-node';
|
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
|
// Host specification (L9-L22, L55-L70)
|
||||||
|
// Bytes conversion
|
||||||
|
function formatBytes(bytes:number, decimals:number = 2) {
|
||||||
|
if (bytes === 0) return '0 Bytes';
|
||||||
|
const k = 1024;
|
||||||
|
const dm = decimals < 0 ? 0 : decimals;
|
||||||
|
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
||||||
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||||
|
};
|
||||||
|
var DJSver = require('discord.js').version;
|
||||||
|
const cpu = await si.cpu();
|
||||||
|
const ram = await si.mem();
|
||||||
|
const osInfo = await si.osInfo();
|
||||||
|
const currentLoad = await si.currentLoad();
|
||||||
|
|
||||||
|
// Command usage (L25-L54)
|
||||||
const columns = ['Command name', 'Count'];
|
const columns = ['Command name', 'Count'];
|
||||||
const includedCommands = client.commands.filter(x=>x.uses).sort((a,b)=>b.uses - a.uses);
|
const includedCommands = client.commands.filter(x=>x.uses).sort((a,b)=>b.uses - a.uses);
|
||||||
if (includedCommands.size == 0) return interaction.reply(`No commands have been used yet.\nUptime: **${client.formatTime(client.uptime as number, 3, {longNames: true, commas: true})}**`);
|
if (includedCommands.size == 0) return interaction.reply(`No commands have been used yet.\nUptime: **${client.formatTime(client.uptime as number, 3, {longNames: true, commas: true})}**`);
|
||||||
@ -36,39 +52,25 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
embed.addFields({name: '\u200b', value: `\`\`\`\n${rows.join('')}\`\`\``})
|
embed.addFields({name: '\u200b', value: `\`\`\`\n${rows.join('')}\`\`\``})
|
||||||
};
|
};
|
||||||
|
embed.addFields(
|
||||||
// Bytes conversion
|
{name: '> __Dependencies__', value: [
|
||||||
function formatBytes(bytes:number, decimals:number = 2) {
|
`**TypeScript:** ${version}`,
|
||||||
if (bytes === 0) return '0 Bytes';
|
`**NodeJS:** ${process.version}`,
|
||||||
const k = 1024;
|
`**DiscordJS:** ${DJSver}`,
|
||||||
const dm = decimals < 0 ? 0 : decimals;
|
`**Axios:** ${client.axios.VERSION}`
|
||||||
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
].join('\n')},
|
||||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
{name: '> __Host__', value: [
|
||||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
`**Operating System:** ${osInfo.distro + ' ' + osInfo.release}`,
|
||||||
}
|
`**CPU:** ${cpu.manufacturer} ${cpu.brand}`,
|
||||||
var DJSver = require('discord.js').version;
|
`**Memory:** ${formatBytes(ram.used)}/${formatBytes(ram.total)}`,
|
||||||
const cpu = await si.cpu();
|
`**NodeJS:** ${formatBytes(process.memoryUsage().heapUsed)}/${formatBytes(process.memoryUsage().heapTotal)}`,
|
||||||
const ram = await si.mem();
|
`**Load Usage:**\nUser: ${currentLoad.currentLoadUser.toFixed(1)}%\nSystem: ${currentLoad.currentLoadSystem.toFixed(1)}%`,
|
||||||
const osInfo = await si.osInfo();
|
`**Uptime:**\nHost: ${client.formatTime((os.uptime()*1000), 2, {longNames: true, commas: true})}\nBot: ${client.formatTime(client.uptime as number, 2, {commas: true, longNames: true})}`
|
||||||
const currentLoad = await si.currentLoad();
|
].join('\n')} // Nice
|
||||||
const embed1 = new client.embed().setColor(client.config.embedColor).setTitle('Statistics: Host Info').setDescription([
|
);
|
||||||
`> __Dependencies__`,
|
interaction.reply({embeds: [embed], fetchReply: true}).then((x)=>x.edit({embeds: [new client.embed(x.embeds[0].data).setFooter({text: `Load time: ${client.formatTime(x.createdTimestamp - interaction.createdTimestamp, 2, {longNames: true, commas: true})}`})]}))
|
||||||
`**TypeScript:** ${version}`,
|
|
||||||
`**TS-Node:** ${VERSION}`,
|
|
||||||
`**NodeJS:** ${process.version}`,
|
|
||||||
`**DiscordJS:** ${DJSver}`,
|
|
||||||
`> __Host__`,
|
|
||||||
`**Operating System:** ${osInfo.distro + ' ' + osInfo.release}`,
|
|
||||||
`**CPU:** ${cpu.manufacturer} ${cpu.brand}`,
|
|
||||||
`**Memory:** ${formatBytes(ram.used)}/${formatBytes(ram.total)}`,
|
|
||||||
`**NodeJS:** ${formatBytes(process.memoryUsage().heapUsed)}/${formatBytes(process.memoryUsage().heapTotal)}`,
|
|
||||||
`**Load Usage:**\nUser: ${currentLoad.currentLoadUser.toFixed(1)}%\nSystem: ${currentLoad.currentLoadSystem.toFixed(1)}%`,
|
|
||||||
`**Uptime:**\nHost: ${client.formatTime((os.uptime()*1000), 2, {longNames: true, commas: true})}\nBot: ${client.formatTime(client.uptime as number, 2, {commas: true, longNames: true})}`
|
|
||||||
].join('\n'))
|
|
||||||
.setFooter({text: `Load time: ${client.formatTime(Date.now() - interaction.createdTimestamp, 2, {longNames: true, commas: true})}`});
|
|
||||||
interaction.reply({embeds: [embed, embed1]})
|
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('statistics')
|
.setName('statistics')
|
||||||
.setDescription('See a list of commands ordered by their usage or bot stats')
|
.setDescription('See a list of commands ordered by their usage or host stats')
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user