diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-23 20:31:16 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-23 20:31:16 -0400 |
commit | 60aabff72f1f501c2d351916e4323bd85c61f5f2 (patch) | |
tree | 45cdc29a9a6a588a53321298832074401d3ae246 | |
parent | 5d33e1aa43444850084b4794b7d870e67dbb474e (diff) | |
download | tanzanite-60aabff72f1f501c2d351916e4323bd85c61f5f2.tar.gz tanzanite-60aabff72f1f501c2d351916e4323bd85c61f5f2.tar.bz2 tanzanite-60aabff72f1f501c2d351916e4323bd85c61f5f2.zip |
funni
-rw-r--r-- | src/commands/dev/eval.ts | 8 | ||||
-rw-r--r-- | src/commands/utilities/calculator.ts | 13 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 10360cf..294c61b 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -119,7 +119,7 @@ export default class EvalCommand extends BushCommand { const inputJS = await util.inspectCleanRedactCodeblock(code.js, 'js'); const inputTS = code.lang === 'ts' ? await util.inspectCleanRedactCodeblock(code.ts, 'ts') : undefined; try { - const rawOutput = code[code.lang]!.replace(/ /g, '').includes('9+10' || '10+9') ? '21' : await eval(code.js); + const rawOutput = /^(9\s*?\+\s*?10)|(10\s*?\+\s*?9)$/.test(code[code.lang]!) ? '21' : await eval(code.js); const output = await util.inspectCleanRedactCodeblock(rawOutput, 'js', { depth: args.sel_depth ?? 0, showHidden: args.hidden, @@ -135,17 +135,17 @@ export default class EvalCommand extends BushCommand { }) : undefined; - embed.setTitle(`${emojis.successFull} Evaluated code successfully`).setColor(colors.success); + embed.setTitle(`${emojis.successFull} Successfully Evaluated Expression`).setColor(colors.success); 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); + embed.setTitle(`${emojis.errorFull} Unable to Evaluate Expression`).setColor(colors.error); if (inputTS) embed.addField('📥 Input (typescript)', inputTS).addField('📥 Input (transpiled javascript)', inputJS); else embed.addField('📥 Input', inputJS); - embed.addField('📤 Output', await util.inspectCleanRedactCodeblock(e?.stack || e, 'js')); + embed.addField('📤 Error', await util.inspectCleanRedactCodeblock(e, 'js')); } embed.setTimestamp().setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true }) ?? undefined); diff --git a/src/commands/utilities/calculator.ts b/src/commands/utilities/calculator.ts index 5f91dca..d845aaa 100644 --- a/src/commands/utilities/calculator.ts +++ b/src/commands/utilities/calculator.ts @@ -39,18 +39,21 @@ export default class CalculatorCommand extends BushCommand { }); } public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }): Promise<unknown> { - const decodedEmbed = new MessageEmbed() - .setTitle(`Calculator`) - .addField('📥 Input', await util.inspectCleanRedactCodeblock(args.expression, 'mma')); + const decodedEmbed = new MessageEmbed().addField( + '📥 Input', + await util.inspectCleanRedactCodeblock(args.expression, 'mma') + ); try { - const calculated = evaluate(args.expression); + const calculated = /^(9\s*?\+\s*?10)|(10\s*?\+\s*?9)$/.test(args.expression) ? '21' : evaluate(args.expression); decodedEmbed + .setTitle(`${util.emojis.successFull} Successfully Calculated Expression`) .setColor(util.colors.success) .addField('📤 Output', await util.inspectCleanRedactCodeblock(calculated.toString(), 'mma')); } catch (error) { decodedEmbed + .setTitle(`${util.emojis.errorFull} Unable to Calculate Expression`) .setColor(util.colors.error) - .addField(`📤 Error Calculating`, await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js')); + .addField(`📤 Error`, await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js')); } return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() }); } |