Resolve user shortcuts and managerEval
This commit is contained in:
parent
538d197f94
commit
ff544dd57b
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user