aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities/calculator.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-23 20:31:16 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-23 20:31:16 -0400
commit60aabff72f1f501c2d351916e4323bd85c61f5f2 (patch)
tree45cdc29a9a6a588a53321298832074401d3ae246 /src/commands/utilities/calculator.ts
parent5d33e1aa43444850084b4794b7d870e67dbb474e (diff)
downloadtanzanite-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.ts13
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() });
}