From 1d3ce9356185ba296e64ad40f6519801cc6102bf Mon Sep 17 00:00:00 2001 From: Trivernis Date: Sun, 3 Feb 2019 15:28:12 +0100 Subject: [PATCH] Modified Dashboard - added Song timer - added active VC count - improved layout - added querying for VC count to graphql --- bot.js | 5 ++-- lib/webapi.js | 14 +++++++++ web/graphql/schema.graphql | 1 + web/http/index.html | 60 +++++++++++++++++++++----------------- web/http/sass/style.sass | 42 +++++++++++++++++++------- web/http/scripts/query.js | 2 ++ 6 files changed, 85 insertions(+), 39 deletions(-) diff --git a/bot.js b/bot.js index a6ba469..f103f3d 100644 --- a/bot.js +++ b/bot.js @@ -112,7 +112,8 @@ class Bot { presences: this.presences, maindb: this.maindb, prefix: prefix, - getGuildHandler: (guild) => this.getGuildHandler(guild, prefix) + getGuildHandler: (guild) => this.getGuildHandler(guild, prefix), + guildHandlers: this.guildHandlers }); } @@ -356,4 +357,4 @@ if (typeof require !== 'undefined' && require.main === module) { logger.error(err.message); }); }); -} \ No newline at end of file +} diff --git a/lib/webapi.js b/lib/webapi.js index 7c01981..287ca20 100644 --- a/lib/webapi.js +++ b/lib/webapi.js @@ -166,6 +166,20 @@ exports.WebServer = class { uptime: () => { return objects.client.uptime; }, + voiceConnectionCount: () => { + let dcGuilds = Array.from(objects.client.guilds.values()); + return dcGuilds.filter((x) => { + let gh = objects.guildHandlers[x.id]; + if (gh) { + if (gh.dj) + return gh.dj.playing; + else + return false; + } else { + return false; + } + }).length;; + } }, prefix: objects.prefix, presences: objects.presences, diff --git a/web/graphql/schema.graphql b/web/graphql/schema.graphql index 0083f16..957e27d 100644 --- a/web/graphql/schema.graphql +++ b/web/graphql/schema.graphql @@ -55,6 +55,7 @@ type Guild { type Client { guilds(first: Int = 10, offset: Int = 0, id: String): [Guild] guildCount: Int + voiceConnectionCount: Int user: User ping: Float status: Int diff --git a/web/http/index.html b/web/http/index.html index fb27838..3bfeecd 100644 --- a/web/http/index.html +++ b/web/http/index.html @@ -39,41 +39,47 @@ Guild Count: +
+ Active Voice Connections: + +