mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-24 22:24:58 +05:00
b0deb2e447
Статистика пользователя и сервера на сайте Удалён лишний файл Отключена комадна someone Фикс currentURL в переменных страниц Обновлена локализация
47 lines
No EOL
1.3 KiB
JavaScript
47 lines
No EOL
1.3 KiB
JavaScript
const express = require("express"),
|
|
utils = require("../utils"),
|
|
CheckAuth = require("../auth/CheckAuth"),
|
|
router = express.Router();
|
|
|
|
router.get("/:serverID", CheckAuth, async (req, res) => {
|
|
// Check if the user has the permissions to edit this guild
|
|
const guild = req.client.guilds.cache.get(req.params.serverID);
|
|
if (!guild || !req.userInfos.displayedGuilds || !req.userInfos.displayedGuilds.find((g) => g.id === req.params.serverID)) {
|
|
return res.render("404", {
|
|
user: req.userInfos,
|
|
translate: req.translate,
|
|
currentURL: `${req.client.config.dashboard.baseURL}${req.originalUrl}`
|
|
});
|
|
}
|
|
|
|
// Fetch guild informations
|
|
const membersData = await req.client.membersData.find({
|
|
guildID: guild.id
|
|
}).lean();
|
|
|
|
const leaderboards = {
|
|
money: utils.sortArrayOfObjects("money", membersData),
|
|
level: utils.sortArrayOfObjects("level", membersData)
|
|
};
|
|
|
|
for (const cat in leaderboards) {
|
|
const e = leaderboards[cat];
|
|
if (e.length > 10) e.length = 10;
|
|
}
|
|
|
|
const stats = {
|
|
money: await utils.fetchUsers(leaderboards.money, req.client),
|
|
level: await utils.fetchUsers(leaderboards.level, req.client)
|
|
};
|
|
|
|
res.render("stats/guild", {
|
|
user: req.userInfos,
|
|
stats,
|
|
bot: req.client,
|
|
guildID: guild.id,
|
|
translate: req.translate,
|
|
currentURL: `${req.client.config.dashboard.baseURL}${req.originalUrl}`,
|
|
});
|
|
});
|
|
|
|
module.exports = router; |