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() {