From 4cc04ea001532f3cf01038ff7d270fe0165e4859 Mon Sep 17 00:00:00 2001 From: gc Date: Tue, 9 Jul 2019 05:46:03 +1000 Subject: [PATCH] add kdh --- bot/index.js | 7 ++----- bot/routes/application.js | 25 +++++++++++++++++++++++++ bot/routes/commands.js | 13 +++++++++++++ config/index.js | 9 +++++++-- 4 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 bot/routes/application.js create mode 100644 bot/routes/commands.js diff --git a/bot/index.js b/bot/index.js index e663f50176..63e8246a6e 100644 --- a/bot/index.js +++ b/bot/index.js @@ -1,12 +1,9 @@ const { Client } = require('klasa'); -const { - token, - clientOptions, - clientProperties -} = require('../config'); +const { token, clientOptions, clientProperties } = require('../config'); Client.use(require('@kcp/tags')); Client.use(require('klasa-textchannel-gateway')); +Client.use(require('klasa-dashboard-hooks')); require('../config/Schemas'); diff --git a/bot/routes/application.js b/bot/routes/application.js new file mode 100644 index 0000000000..205a3e024f --- /dev/null +++ b/bot/routes/application.js @@ -0,0 +1,25 @@ +const { Route } = require('klasa-dashboard-hooks'); +const { Duration } = require('klasa'); + +module.exports = class extends Route { + + constructor(...args) { + super(...args, { route: 'application' }); + } + + get(request, response) { + return response.end( + JSON.stringify({ + users: this.client.users.size, + guilds: this.client.guilds.size, + channels: this.client.channels.size, + shards: this.client.options.shardCount, + uptime: Duration.toNow(Date.now() - process.uptime() * 1000), + memory: process.memoryUsage().heapUsed / 1024 / 1024, + invite: this.client.invite, + ...this.client.application + }) + ); + } + +}; diff --git a/bot/routes/commands.js b/bot/routes/commands.js new file mode 100644 index 0000000000..4689a212b4 --- /dev/null +++ b/bot/routes/commands.js @@ -0,0 +1,13 @@ +const { Route } = require('klasa-dashboard-hooks'); + +module.exports = class extends Route { + + constructor(...args) { + super(...args, { route: 'commands' }); + } + + get(request, response) { + return response.end(JSON.stringify(this.client.commands)); + } + +}; diff --git a/config/index.js b/config/index.js index 571be06d6e..46186f96af 100644 --- a/config/index.js +++ b/config/index.js @@ -1,6 +1,6 @@ const emoji = require('./skill-emoji'); const streamers = require('../data/osrs-streamers'); -const { token, twitchClientID, twitterApp, dbl } = require('./private.js'); +const { token, twitchClientID, twitterApp, dbl, clientSecret, KDHOptions } = require('./private.js'); const production = require('os').platform() === 'linux'; @@ -48,6 +48,11 @@ module.exports = { providers: { default: production ? 'rethinkdb' : 'json' }, permissionLevels: require('./PermissionLevels'), pieceDefaults: { commands: { deletable: true } }, - readyMessage: client => `[Old School Bot] Ready to serve ${client.guilds.size} guilds and ${client.users.size} users` + readyMessage: client => + `[Old School Bot] Ready to serve ${client.guilds.size} guilds and ${client.users.size} users`, + /* KDH */ + clientSecret, + clientID: '303730326692429825', + dashboardHooks: KDHOptions } };