diff --git a/pages/get/admin.js b/pages/get/admin.js index 9a49b777..da640d09 100644 --- a/pages/get/admin.js +++ b/pages/get/admin.js @@ -3,7 +3,7 @@ const db = require('quick.db') module.exports = { page: '/admin', - execute: async (req, res, app, config, themeConfig, info) => { + execute: async (req, res, app, config, themeConfig, info, database) => { const pterodactyl = new Nodeactyl.NodeactylClient( themeConfig.admin.pterodactyl.panelLink, themeConfig.admin.pterodactyl.apiKey @@ -40,6 +40,7 @@ module.exports = { res.render('admin', { req, sData: d, + ldata: await database.get('logs'), themeConfig: req.themeConfig, node: pterodactyl, bot: config.bot, @@ -48,4 +49,4 @@ module.exports = { require }) } -} +} \ No newline at end of file diff --git a/pages/post/logs.js b/pages/post/logs.js new file mode 100644 index 00000000..a52479ff --- /dev/null +++ b/pages/post/logs.js @@ -0,0 +1,23 @@ +module.exports = { + page: '/stats/logs/update', + execute: async (req, res, app, config, themeConfig, info, db) => { + if ( + 'Bearer ' + themeConfig.admin.logs?.key !== + req.headers.authorization + ) + return res.json({ status: 'Invalid sharding key' }) + + const logs = await db.get('logs') + + let newLogs = [] + + if (!logs || !logs.length || !logs[0]) + newLogs = [req.body] + else + newLogs = [req.body, ...logs] + + await db.set('logs', newLogs) + + res.json({ status: 'Completed' }) + } +} \ No newline at end of file diff --git a/views/admin.ejs b/views/admin.ejs index a742efdc..235c95cc 100644 --- a/views/admin.ejs +++ b/views/admin.ejs @@ -491,6 +491,27 @@ +
+ <% } %> + <% if (themeConfig.admin.logs?.enabled) { %> +
+
+
Bot Logs
+
+
+
Current Logs
+
+
+ <% if (ldata !== undefined) { %> + + <% } else { %> + + <% } %> +
+
+
+
+
<% } %>