1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-12 23:20:17 +00:00
musix-oss/commands/cmduses.js

31 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-02-09 09:53:30 +00:00
const { EmbedBuilder } = require("discord.js");
2019-11-25 18:48:56 +00:00
module.exports = {
name: 'cmduses',
usage: '',
description: 'Command usage statistics',
uses: 0,
2024-02-09 09:53:30 +00:00
async execute(msg, args, client) {
2019-11-25 18:48:56 +00:00
const cmduses = [];
client.commands.forEach((value, key) => {
cmduses.push([key, value.uses]);
});
cmduses.sort((a, b) => {
return b[1] - a[1];
});
const cmdnamelength = Math.max(...cmduses.map(x => x[0].length)) + 4;
const numberlength = Math.max(...cmduses.map(x => x[1].toString().length), 4);
const markdownrows = ['Command' + ' '.repeat(cmdnamelength - 'command'.length) + ' '.repeat(numberlength - 'uses'.length) + 'Uses'];
cmduses.forEach(x => {
if (x[1] > 0) markdownrows.push(x[0] + '.'.repeat(cmdnamelength - x[0].length) + ' '.repeat(numberlength - x[1].toString().length) + x[1].toString());
});
2024-02-09 09:53:30 +00:00
const embed = new EmbedBuilder();
2019-11-25 18:48:56 +00:00
embed
.setTitle('Musix Command Usage During Current Uptime')
.setDescription('```ml\n' + markdownrows.join('\n') + '\n```')
2024-02-09 09:53:30 +00:00
.setFooter({ text: 'These statistics are from the current uptime.' })
2019-12-05 13:17:15 +00:00
.setColor(client.config.embedColor);
2024-02-09 09:53:30 +00:00
msg.channel.send({ embeds: [embed] });
2019-11-25 18:48:56 +00:00
},
2024-02-09 09:53:30 +00:00
};