mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add total uses stat
This commit is contained in:
@@ -32,6 +32,8 @@ module.exports = class CommandLeaderboardCommand extends Command {
|
|||||||
return msg.say(stripIndents`
|
return msg.say(stripIndents`
|
||||||
__**Command Usage Leaderboard (Page ${page}/${totalPages}):**__
|
__**Command Usage Leaderboard (Page ${page}/${totalPages}):**__
|
||||||
${this.makeLeaderboard(commands, page).join('\n')}
|
${this.makeLeaderboard(commands, page).join('\n')}
|
||||||
|
|
||||||
|
_Total Uses: ${formatNumber(this.client.registry.totalUses)}_
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ module.exports = class InfoCommand extends Command {
|
|||||||
.setFooter({ text: copyright.join('\n') })
|
.setFooter({ text: copyright.join('\n') })
|
||||||
.addField('❯ Servers', formatNumber(this.client.guilds.cache.size), true)
|
.addField('❯ Servers', formatNumber(this.client.guilds.cache.size), true)
|
||||||
.addField('❯ Commands', formatNumber(this.client.registry.commands.size), true)
|
.addField('❯ Commands', formatNumber(this.client.registry.commands.size), true)
|
||||||
.addField('❯ Shards', formatNumber(this.client.options.shardCount), true)
|
.addField('❯ Total Usage', formatNumber(this.client.registry.totalUses), true)
|
||||||
.addField('❯ Home Server',
|
.addField('❯ Home Server',
|
||||||
this.client.options.invite ? embedURL('Invite', this.client.options.invite) : 'None', true)
|
this.client.options.invite ? embedURL('Invite', this.client.options.invite) : 'None', true)
|
||||||
.addField('❯ Invite', embedURL('Add Me', invite), true)
|
.addField('❯ Invite', embedURL('Add Me', invite), true)
|
||||||
|
|||||||
@@ -12,13 +12,18 @@ module.exports = class UsesCommand extends Command {
|
|||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'command',
|
key: 'command',
|
||||||
type: 'command'
|
type: 'command',
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
run(msg, { command }) {
|
run(msg, { command }) {
|
||||||
|
if (!command) {
|
||||||
|
const uses = formatNumber(this.client.registry.totalUses);
|
||||||
|
return msg.say(`All commands have been used a total of **${uses}** times.`);
|
||||||
|
}
|
||||||
if (command.unknown || command.uses === undefined) {
|
if (command.unknown || command.uses === undefined) {
|
||||||
return msg.reply('That command\'s usage stats aren\'t being tracked.');
|
return msg.reply('That command\'s usage stats aren\'t being tracked.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,4 +78,13 @@ module.exports = class Registry {
|
|||||||
registerDefaultTypes() {
|
registerDefaultTypes() {
|
||||||
return this.registerTypesIn(path.join(__dirname, 'types'));
|
return this.registerTypesIn(path.join(__dirname, 'types'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get totalUses() {
|
||||||
|
let uses = 0;
|
||||||
|
for (const command of this.commands.values()) {
|
||||||
|
if (command.ownerOnly || command.unknown || command.uses === undefined) continue;
|
||||||
|
uses += command.uses;
|
||||||
|
}
|
||||||
|
return uses;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "152.0.2",
|
"version": "152.1.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -65,5 +65,9 @@ module.exports = [
|
|||||||
{
|
{
|
||||||
text: client => `with ${formatNumber(client.registry.commands.size)} commands`,
|
text: client => `with ${formatNumber(client.registry.commands.size)} commands`,
|
||||||
type: ActivityType.Playing
|
type: ActivityType.Playing
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: client => `with ${formatNumber(client.registry.totalUses)} command uses`,
|
||||||
|
type: ActivityType.Playing
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user