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 /src/commands/utilities/calculator.ts | |
parent | 5d33e1aa43444850084b4794b7d870e67dbb474e (diff) | |
download | tanzanite-60aabff72f1f501c2d351916e4323bd85c61f5f2.tar.gz tanzanite-60aabff72f1f501c2d351916e4323bd85c61f5f2.tar.bz2 tanzanite-60aabff72f1f501c2d351916e4323bd85c61f5f2.zip |
funni
Diffstat (limited to 'src/commands/utilities/calculator.ts')
-rw-r--r-- | src/commands/utilities/calculator.ts | 13 |
1 files changed, 8 insertions, 5 deletions
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() }); } |