mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 01:57:54 +02:00
Filter hidden and unknown commands out of lb
This commit is contained in:
@@ -23,20 +23,20 @@ module.exports = class CommandLeaderboardCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run(msg, { page }) {
|
run(msg, { page }) {
|
||||||
const totalPages = Math.ceil(this.client.registry.commands.size / 10);
|
const commands = this.filterCommands(this.client.registry.commands);
|
||||||
|
const totalPages = Math.ceil(commands.size / 10);
|
||||||
if (page > totalPages) return msg.say(`Page ${page} does not exist (yet).`);
|
if (page > totalPages) return msg.say(`Page ${page} does not exist (yet).`);
|
||||||
return msg.say(stripIndents`
|
return msg.say(stripIndents`
|
||||||
__**Command Usage Leaderboard (Page ${page}/${totalPages}):**__
|
__**Command Usage Leaderboard (Page ${page}/${totalPages}):**__
|
||||||
${this.makeLeaderboard(page).join('\n')}
|
${this.makeLeaderboard(commands, page).join('\n')}
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLeaderboard(page) {
|
makeLeaderboard(commands, page) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let previousPts = null;
|
let previousPts = null;
|
||||||
let positionsMoved = 1;
|
let positionsMoved = 1;
|
||||||
return this.client.registry.commands
|
return commands
|
||||||
.filter(command => command.uses !== undefined)
|
|
||||||
.sort((a, b) => b.uses - a.uses)
|
.sort((a, b) => b.uses - a.uses)
|
||||||
.map(command => {
|
.map(command => {
|
||||||
if (previousPts === command.uses) {
|
if (previousPts === command.uses) {
|
||||||
@@ -50,4 +50,8 @@ module.exports = class CommandLeaderboardCommand extends Command {
|
|||||||
})
|
})
|
||||||
.slice((page - 1) * 10, page * 10);
|
.slice((page - 1) * 10, page * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filterCommands(commands) {
|
||||||
|
return commands.filter(command => command.uses !== undefined && !command.unknown && !command.hidden);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "116.27.2",
|
"version": "116.27.3",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user