mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 06:37:32 +02:00
Command Leaderboard
This commit is contained in:
@@ -67,6 +67,8 @@ client.on('warn', console.warn);
|
|||||||
|
|
||||||
client.on('commandError', (command, err) => console.error(command.name, err));
|
client.on('commandError', (command, err) => console.error(command.name, err));
|
||||||
|
|
||||||
|
client.on('commandRun', command => ++command.uses);
|
||||||
|
|
||||||
client.on('guildCreate', async () => {
|
client.on('guildCreate', async () => {
|
||||||
const guilds = await client.shard.fetchClientValues('guilds.size');
|
const guilds = await client.shard.fetchClientValues('guilds.size');
|
||||||
const count = guilds.reduce((prev, val) => prev + val, 0);
|
const count = guilds.reduce((prev, val) => prev + val, 0);
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
|
||||||
|
module.exports = class CommandLeaderboardCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'command-leaderboard',
|
||||||
|
aliases: ['cmd-leaderboard', 'cmd-board'],
|
||||||
|
group: 'util',
|
||||||
|
memberName: 'command-leaderboard',
|
||||||
|
description: 'Responds with the most used commands on this shard since the last restart.',
|
||||||
|
guarded: true,
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'page',
|
||||||
|
prompt: 'Which page do you want to view?',
|
||||||
|
type: 'integer',
|
||||||
|
default: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run(msg, { page }) {
|
||||||
|
let i = 0;
|
||||||
|
const list = this.client.registry.commands
|
||||||
|
.filter(cmd => cmd.uses)
|
||||||
|
.sort((a, b) => b.uses - a.uses)
|
||||||
|
.map(cmd => `**${++i}.** ${cmd.name} (${cmd.uses} Uses)`)
|
||||||
|
.slice((page - 1) * 10, page * 10);
|
||||||
|
return msg.say(list.split('\n') || 'None yet.');
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "42.11.0",
|
"version": "42.12.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class XiaoCommand extends Command {
|
|||||||
usages: 1,
|
usages: 1,
|
||||||
duration: 2
|
duration: 2
|
||||||
};
|
};
|
||||||
|
this.uses = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasPermission(msg) {
|
hasPermission(msg) {
|
||||||
|
|||||||
Reference in New Issue
Block a user