mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-25 06:34:58 +05:00
Покрасивше сделал
This commit is contained in:
parent
e444c8bd0c
commit
feae708948
1 changed files with 14 additions and 7 deletions
|
@ -21,7 +21,7 @@ class Leaderboard extends Command {
|
||||||
const isOnlyOnMobile = (message.member.presence.clientStatus ? JSON.stringify(Object.keys(message.member.presence.clientStatus)) === JSON.stringify(["mobile"]) : false);
|
const isOnlyOnMobile = (message.member.presence.clientStatus ? JSON.stringify(Object.keys(message.member.presence.clientStatus)) === JSON.stringify(["mobile"]) : false);
|
||||||
|
|
||||||
const type = args[0];
|
const type = args[0];
|
||||||
if (!type || (type !== "credits" && type !== "level" && type !== "rep")) return message.error("economy/leaderboard:MISSING_TYPE");
|
if (!type || !["credits", "level", "rep"].includes(type)) return message.error("economy/leaderboard:MISSING_TYPE");
|
||||||
|
|
||||||
if (type === "credits") {
|
if (type === "credits") {
|
||||||
const members = await this.client.membersData.find({
|
const members = await this.client.membersData.find({
|
||||||
|
@ -33,12 +33,15 @@ class Leaderboard extends Command {
|
||||||
value: m.money + m.bankSold
|
value: m.money + m.bankSold
|
||||||
};
|
};
|
||||||
}).sort((a, b) => b.value - a.value);
|
}).sort((a, b) => b.value - a.value);
|
||||||
|
|
||||||
const table = new AsciiTable("Таблица лидеров");
|
const table = new AsciiTable("Таблица лидеров");
|
||||||
table.setHeading("#", message.translate("common:USER"), message.translate("common:CREDITS"));
|
table.setHeading("#", message.translate("common:USER"), message.translate("common:CREDITS"));
|
||||||
|
|
||||||
if (membersLeaderboard.length > 20) membersLeaderboard.length = 20;
|
if (membersLeaderboard.length > 20) membersLeaderboard.length = 20;
|
||||||
|
|
||||||
const newTable = await fetchUsers(membersLeaderboard, table, this.client);
|
const newTable = await fetchUsers(membersLeaderboard, table, this.client);
|
||||||
message.channel.send({
|
message.channel.send({
|
||||||
content: `\`\`\`\n${newTable.toString()}\`\`\``
|
content: "```\n" + newTable.toString() + "```"
|
||||||
});
|
});
|
||||||
} else if (type === "level") {
|
} else if (type === "level") {
|
||||||
const members = await this.client.membersData.find({
|
const members = await this.client.membersData.find({
|
||||||
|
@ -50,18 +53,19 @@ class Leaderboard extends Command {
|
||||||
value: m.level
|
value: m.level
|
||||||
};
|
};
|
||||||
}).sort((a, b) => b.value - a.value);
|
}).sort((a, b) => b.value - a.value);
|
||||||
|
|
||||||
const table = new AsciiTable("Таблица лидеров");
|
const table = new AsciiTable("Таблица лидеров");
|
||||||
table.setHeading("#", message.translate("common:USER"), message.translate("common:LEVEL"));
|
table.setHeading("#", message.translate("common:USER"), message.translate("common:LEVEL"));
|
||||||
|
|
||||||
if (membersLeaderboard.length > 20) membersLeaderboard.length = 20;
|
if (membersLeaderboard.length > 20) membersLeaderboard.length = 20;
|
||||||
|
|
||||||
const newTable = await fetchUsers(membersLeaderboard, table, this.client);
|
const newTable = await fetchUsers(membersLeaderboard, table, this.client);
|
||||||
message.channel.send({
|
message.channel.send({
|
||||||
content: `\`\`\`\n${newTable.toString()}\`\`\``
|
content: "```\n" + newTable.toString() + "```"
|
||||||
});
|
});
|
||||||
} else if (type === "rep") {
|
} else if (type === "rep") {
|
||||||
const users = await this.client.usersData.find({
|
const users = await this.client.usersData.find({
|
||||||
rep: {
|
rep: { $gt: 0 }
|
||||||
$gt: 0
|
|
||||||
}
|
|
||||||
}).lean(),
|
}).lean(),
|
||||||
usersLeaderboard = users.map((u) => {
|
usersLeaderboard = users.map((u) => {
|
||||||
return {
|
return {
|
||||||
|
@ -69,12 +73,15 @@ class Leaderboard extends Command {
|
||||||
value: u.rep
|
value: u.rep
|
||||||
};
|
};
|
||||||
}).sort((a, b) => b.value - a.value);
|
}).sort((a, b) => b.value - a.value);
|
||||||
|
|
||||||
const table = new AsciiTable("Таблица лидеров");
|
const table = new AsciiTable("Таблица лидеров");
|
||||||
table.setHeading("#", message.translate("common:USER"), message.translate("common:POINTS"));
|
table.setHeading("#", message.translate("common:USER"), message.translate("common:POINTS"));
|
||||||
|
|
||||||
if (usersLeaderboard.length > 20) usersLeaderboard.length = 20;
|
if (usersLeaderboard.length > 20) usersLeaderboard.length = 20;
|
||||||
|
|
||||||
const newTable = await fetchUsers(usersLeaderboard, table, this.client);
|
const newTable = await fetchUsers(usersLeaderboard, table, this.client);
|
||||||
message.channel.send({
|
message.channel.send({
|
||||||
content: `\`\`\`\n${newTable.toString()}\`\`\``
|
content: "```\n" + newTable.toString() + "```"
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue