JaBa/dashboard/routes/user.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

const express = require("express"),
utils = require("../utils"),
CheckAuth = require("../auth/CheckAuth"),
router = express.Router();
// Gets user page
router.get("/:userID/:serverID", CheckAuth, async function (req, res) {
const guild = req.client.guilds.cache.get(req.params.serverID);
2022-01-13 21:44:19 +05:00
if (!guild) {
return res.render("404", {
user: req.userInfos,
translate: req.translate,
currentURL: `${req.client.config.dashboard.baseURL}${req.originalUrl}`
});
}
const guildData = await req.client.findOrCreateGuild({ id: guild.id });
2022-01-13 22:53:33 +05:00
const userInfos = await utils.fetchUser({
id: req.params.userID
}, req.client).catch(() => {
res.render("404", {
user: req.userInfos,
translate: req.translate,
currentURL: `${req.client.config.dashboard.baseURL}${req.originalUrl}`
});
});
res.render("user", {
user: req.userInfos,
2022-01-13 22:53:33 +05:00
userInfos: userInfos,
guild: guildData,
bot: req.client,
translate: req.translate,
printDate: req.printDate,
currentURL: `${req.client.config.dashboard.baseURL}${req.originalUrl}`
});
});
module.exports = router;