aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev/eval.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-16 10:04:46 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-16 10:04:46 -0400
commit4501e9f3bdd016736844146020e6b2c15e2ab3d2 (patch)
tree6e8a7c3d2b11dac7dcfd6afe0c46e4f42e682da3 /src/commands/dev/eval.ts
parent59087bf0d8fa504da997594fc62787695e689476 (diff)
downloadtanzanite-4501e9f3bdd016736844146020e6b2c15e2ab3d2.tar.gz
tanzanite-4501e9f3bdd016736844146020e6b2c15e2ab3d2.tar.bz2
tanzanite-4501e9f3bdd016736844146020e6b2c15e2ab3d2.zip
add viewraw context menu command
Diffstat (limited to 'src/commands/dev/eval.ts')
-rw-r--r--src/commands/dev/eval.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts
index 19667dd..5b44db2 100644
--- a/src/commands/dev/eval.ts
+++ b/src/commands/dev/eval.ts
@@ -22,6 +22,11 @@ export default class EvalCommand extends BushCommand {
{ id: 'typescript', match: 'flag', flag: '--ts' },
{ id: 'hidden', match: 'flag', flag: '--hidden' },
{ id: 'show_proto', match: 'flag', flag: '--proto' },
+ // {
+ // id: 'show_methods',
+ // match: 'flag',
+ // flag: ['--func', '--function', '--functions', '--meth', '--method', '--methods']
+ // },
{
id: 'code',
match: 'rest',
@@ -38,6 +43,7 @@ export default class EvalCommand extends BushCommand {
{ name: 'typescript', description: 'Whether or not the code is typescript.', type: 'BOOLEAN', required: false },
{ name: 'hidden', description: 'Whether or not to show hidden items.', type: 'BOOLEAN', required: false },
{ name: 'show_proto', description: 'Show prototype.', type: 'BOOLEAN', required: false }
+ // { name: 'show_methods', description: 'Show class functions.', type: 'BOOLEAN', required: false }
],
ownerOnly: true
});
@@ -54,6 +60,7 @@ export default class EvalCommand extends BushCommand {
typescript: boolean;
hidden: boolean;
show_proto: boolean;
+ // show_methods: boolean;
}
): Promise<unknown> {
if (!message.author.isOwner())
@@ -114,11 +121,12 @@ export default class EvalCommand extends BushCommand {
try {
const rawOutput = code[code.lang].replace(/ /g, '').includes('9+10' || '10+9') ? '21' : await eval(code.js);
const output = await util.inspectCleanRedactCodeblock(rawOutput, 'js', {
- depth: args.sel_depth || 0,
+ depth: args.sel_depth ?? 0,
showHidden: args.hidden,
getters: true,
showProxy: true
});
+ // const methods = args.show_methods ? await util.inspectCleanRedactCodeblock(util.getMethods(rawOutput), 'js') : undefined;
const proto = args.show_proto
? await util.inspectCleanRedactCodeblock(Object.getPrototypeOf(rawOutput), 'js', {
depth: 1,
@@ -131,6 +139,7 @@ export default class EvalCommand extends BushCommand {
if (inputTS) embed.addField('📥 Input (typescript)', inputTS).addField('📥 Input (transpiled javascript)', inputJS);
else embed.addField('📥 Input', inputJS);
embed.addField('📤 Output', output);
+ // if (methods) embed.addField('🔧 Methods', methods);
if (proto) embed.addField('⚙️ Proto', proto);
} catch (e) {
embed.setTitle(`${emojis.errorFull} Code was not able to be evaluated.`).setColor(colors.error);