2020-02-05 20:02:53 +00:00
|
|
|
module.exports = {
|
|
|
|
name: 'cmduses',
|
|
|
|
alias: 'none',
|
2020-02-24 18:41:40 +00:00
|
|
|
usage: '',
|
2020-02-05 20:02:53 +00:00
|
|
|
description: 'list all commands and how many times they\'ve been used',
|
|
|
|
onlyDev: true,
|
|
|
|
permission: 'dev',
|
|
|
|
category: 'info',
|
2020-03-14 16:38:02 +00:00
|
|
|
async execute(msg, args, client, Discord, prefix, command) {
|
2020-02-05 20:02:53 +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());
|
|
|
|
});
|
|
|
|
const embed = new Discord.MessageEmbed();
|
|
|
|
embed
|
2020-03-12 21:07:44 +00:00
|
|
|
.setTitle(client.messages.cmdUsesTitle)
|
2020-02-05 20:02:53 +00:00
|
|
|
.setDescription('```ml\n' + markdownrows.join('\n') + '\n```')
|
2020-03-12 21:07:44 +00:00
|
|
|
.setFooter(client.messages.cmdUsesFooter)
|
2020-02-05 20:02:53 +00:00
|
|
|
.setColor(client.config.embedColor);
|
|
|
|
msg.channel.send(embed);
|
|
|
|
},
|
|
|
|
};
|