1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 04:10:59 -05:00

combine both embeds into one command

This commit is contained in:
toast-ts 2022-11-30 19:34:53 +11:00
parent f2c8ba088c
commit dd8ec39947

View File

@ -6,8 +6,7 @@ import { versionMajorMinor } from 'typescript';
import { VERSION } from 'ts-node'; 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'>){
switch (interaction.options.getSubcommand()) { await interaction.deferReply();
case 'commands':
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, 2, {longNames: true, commas: true})}`); if (includedCommands.size == 0) return interaction.reply(`No commands have been used yet.\nUptime: ${client.formatTime(client.uptime as number, 2, {longNames: true, commas: true})}`);
@ -38,9 +37,7 @@ export default {
} else { } else {
embed.addFields({name: '\u200b', value: `\`\`\`\n${rows.join('')}\`\`\``}) embed.addFields({name: '\u200b', value: `\`\`\`\n${rows.join('')}\`\`\``})
}; };
interaction.reply({embeds: [embed]})
break;
case 'host':
// Bytes conversion // Bytes conversion
function formatBytes(bytes, decimals = 2) { function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return '0 Bytes'; if (bytes === 0) return '0 Bytes';
@ -50,7 +47,6 @@ export default {
const i = Math.floor(Math.log(bytes) / Math.log(k)); const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
} }
await interaction.deferReply();
const cpu = await si.cpu(); const cpu = await si.cpu();
const ram = await si.mem(); const ram = await si.mem();
const osInfo = await si.osInfo(); const osInfo = await si.osInfo();
@ -70,17 +66,10 @@ export default {
`**Uptime:**\nHost: ${client.formatTime((os.uptime()*1000), 2, {longNames: true, commas: true})}\nBot: ${client.formatTime(client.uptime as number, 2, {commas: true, longNames: true})}` `**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')) ].join('\n'))
.setFooter({text: `Load time: ${Date.now() - interaction.createdTimestamp}ms`}); .setFooter({text: `Load time: ${Date.now() - interaction.createdTimestamp}ms`});
interaction.editReply({embeds: [embed1]}); interaction.editReply({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 bot stats')
.setDMPermission(false) .setDMPermission(false)
.addSubcommand((opt)=>opt
.setName('commands')
.setDescription('View command usage stats'))
.addSubcommand((opt)=>opt
.setName('host')
.setDescription('View host stats'))
} }