discord-easy-dashboard
Version:
💻 Complete framework to facilitate the creation of dashboard using discord.js and express
34 lines (31 loc) • 1.11 kB
JavaScript
const { Router } = require('express');
const Commands = Router().get('/*', function(req, res) {
const path = req.baseUrl.split('/').pop();
if (!req.dashboardConfig.theme[path]) {
const file = req.dashboardConfig.theme['404'] || '404.ejs';
return res.status(404).render(file, {
bot: req.client,
user: req.user,
is_logged: Boolean(req.session.user),
dashboardDetails: req.dashboardDetails,
dashboardConfig: req.dashboardConfig,
baseUrl: req.dashboardConfig.baseUrl,
port: req.dashboardConfig.port,
hasClientSecret: Boolean(req.dashboardConfig.secret),
commands: req.dashboardCommands,
});
}
res.status(200).render(req.dashboardConfig.theme[path], {
bot: req.client,
user: req.user,
is_logged: Boolean(req.session.user),
dashboardDetails: req.dashboardDetails,
dashboardConfig: req.dashboardConfig,
baseUrl: req.dashboardConfig.baseUrl,
port: req.dashboardConfig.port,
hasClientSecret: Boolean(req.dashboardConfig.secret),
commands: req.dashboardCommands,
});
});
module.exports.Router = Commands;
module.exports.name = '/*';