stringify script for manager eval

This commit is contained in:
Erik 2022-05-11 20:44:25 +03:00
parent d10ec5020a
commit 187727fd90
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -1,4 +1,4 @@
const { Client, Collection } = require('discord.js'); const { Client, Collection, Options } = require('discord.js');
const chalk = require('chalk'); const chalk = require('chalk');
const { inspect } = require('util'); const { inspect } = require('util');
@ -129,8 +129,9 @@ class DiscordClient extends Client {
if (message._evalResult) this.evalResult(message); if (message._evalResult) this.evalResult(message);
} }
async managerEval(script) { async managerEval(script, options = {}) {
if(typeof script === 'function') script = `(${script})(this, ${JSON.stringify(options.context)})`;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._evals.set(script, { resolve, reject }); this._evals.set(script, { resolve, reject });