From bfe29e0ef49164f68402ac68cebc0d0c179d8e7e Mon Sep 17 00:00:00 2001 From: Trivernis Date: Sat, 2 Feb 2019 23:40:41 +0100 Subject: [PATCH] Dashboard modifications - finished most functionalities of the dashboard - fixed some bugs --- bot.js | 2 +- lib/webapi.js | 41 ++++++----- web/http/index.html | 42 ++++++++++- web/http/sass/style.sass | 68 +++++++++++++++++- web/http/scripts/query.js | 143 ++++++++++++++++++++++++++++++++++++-- 5 files changed, 270 insertions(+), 26 deletions(-) diff --git a/bot.js b/bot.js index 1ed5428..9997b5d 100644 --- a/bot.js +++ b/bot.js @@ -327,7 +327,7 @@ class Bot { (this.mention) ? msg.reply(answer) : msg.channel.send(answer); } } else { - logger.warn(`Empty answer won't be send.`); + logger.verbose(`Empty answer won't be send.`); } } diff --git a/lib/webapi.js b/lib/webapi.js index f0326bd..fdcfd0e 100644 --- a/lib/webapi.js +++ b/lib/webapi.js @@ -60,12 +60,12 @@ exports.WebServer = class { * @returns {Promise} */ stop() { - return new Promise((resolve) => { - if (this.server) - this.server.close(() => resolve()); - else - resolve(); - }) + return new Promise((resolve) => { + if (this.server) + this.server.close(() => resolve()); + else + resolve(); + }) } /** @@ -79,13 +79,13 @@ exports.WebServer = class { let token = generateID(['TOKEN', username, (new Date()).getMilliseconds()]); this.maindb.run('INSERT INTO users (username, token, scope) VALUES (?, ?, ?)', [username, token, scope], (err) => { - if(err) { - logger.warn(err.message); - reject(err); - } else { - resolve(token); - } - }) + if (err) { + logger.warn(err.message); + reject(err); + } else { + resolve(token); + } + }) }); } @@ -141,9 +141,14 @@ exports.WebServer = class { .map((x) => new Guild(x, objects.getGuildHandler(x))) .find(x => (x.id === args.id))]; } else { - return Array.from(dcGuilds) - .map((x) => new Guild(x, objects.getGuildHandler(x))) - .slice(args.offset, args.offset + args.first); + try { + return Array.from(dcGuilds) + .slice(args.offset, args.offset + args.first) + .map((x) => new Guild(x, objects.getGuildHandler(x))); + } catch (err) { + logger.error(err.stack); + return null; + } } }, guildCount: () => { @@ -279,7 +284,7 @@ class Guild { this.ready = guildHandler.ready; this.prSaved = null; this.guildHandler = guildHandler; - this.dj = this.guildHandler.dj? new DJ(this.guildHandler.dj) : null; + this.dj = this.guildHandler.dj ? new DJ(this.guildHandler.dj) : null; } querySaved() { @@ -393,7 +398,7 @@ class User { this.tag = discordUser.tag; this.tag = discordUser.tag; this.presence = { - game: discordUser.presence.game.name, + game: discordUser.presence.game? discordUser.presence.game.name : null, status: discordUser.presence.status } } diff --git a/web/http/index.html b/web/http/index.html index ecf734d..1b44a15 100644 --- a/web/http/index.html +++ b/web/http/index.html @@ -42,7 +42,47 @@
-

right

+ +