From ff544dd57b8d96fa696c69f487c4f42c474443f3 Mon Sep 17 00:00:00 2001 From: Navy Date: Fri, 14 Aug 2020 17:13:29 +0300 Subject: [PATCH] Resolve user shortcuts and managerEval --- structure/client/DiscordClient.js | 36 ++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/structure/client/DiscordClient.js b/structure/client/DiscordClient.js index 4e51498..5b8ccd3 100644 --- a/structure/client/DiscordClient.js +++ b/structure/client/DiscordClient.js @@ -40,6 +40,8 @@ class DiscordClient extends Client { //TODO: Default config for users and guilds. this._defaultConfig = null; + this._evals = new Map(); + process.on('message', this._handleMessage.bind(this)); } @@ -70,9 +72,41 @@ class DiscordClient extends Client { } + async resolveUsers() { + + return this.resolver.resolveUsers(...arguments); + + } + + async resolveUser() { + + return this.resolver.resolveUser(...arguments); + + } + async _handleMessage(message) { //Handle misc. messages. - + if (message._evalResult) this.evalResult(message); + } + + async managerEval(script) { + + return new Promise((resolve, reject) => { + + this._evals.set(script, { resolve, reject }); + process.send({ _mEval: true, script }); + + }); + + } + + evalResult({ script, result, error }) { + + const promise = this._evals.get(script); + if (result) promise.resolve(result); + else promise.reject(error); + this._evals.delete(script); + } get defaultConfig() {