mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 00:10:58 -05:00
combine both embeds into one command
This commit is contained in:
parent
f2c8ba088c
commit
dd8ec39947
@ -6,8 +6,7 @@ import { versionMajorMinor } from 'typescript';
|
||||
import { VERSION } from 'ts-node';
|
||||
export default {
|
||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||
switch (interaction.options.getSubcommand()) {
|
||||
case 'commands':
|
||||
await interaction.deferReply();
|
||||
const columns = ['Command name', 'Count'];
|
||||
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})}`);
|
||||
@ -38,9 +37,7 @@ export default {
|
||||
} else {
|
||||
embed.addFields({name: '\u200b', value: `\`\`\`\n${rows.join('')}\`\`\``})
|
||||
};
|
||||
interaction.reply({embeds: [embed]})
|
||||
break;
|
||||
case 'host':
|
||||
|
||||
// Bytes conversion
|
||||
function formatBytes(bytes, decimals = 2) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
@ -50,7 +47,6 @@ export default {
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
await interaction.deferReply();
|
||||
const cpu = await si.cpu();
|
||||
const ram = await si.mem();
|
||||
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})}`
|
||||
].join('\n'))
|
||||
.setFooter({text: `Load time: ${Date.now() - interaction.createdTimestamp}ms`});
|
||||
interaction.editReply({embeds: [embed1]});
|
||||
}
|
||||
interaction.editReply({embeds: [embed, embed1]});
|
||||
},
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('statistics')
|
||||
.setDescription('See a list of commands ordered by their usage or bot stats')
|
||||
.setDMPermission(false)
|
||||
.addSubcommand((opt)=>opt
|
||||
.setName('commands')
|
||||
.setDescription('View command usage stats'))
|
||||
.addSubcommand((opt)=>opt
|
||||
.setName('host')
|
||||
.setDescription('View host stats'))
|
||||
}
|
Loading…
Reference in New Issue
Block a user