mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-08 15:19:14 +02:00
23
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const math = require('mathjs');
|
||||
|
||||
module.exports = class MathCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'math',
|
||||
group: 'num-edit',
|
||||
memberName: 'math',
|
||||
description: 'Evaluates math expressions.',
|
||||
args: [
|
||||
{
|
||||
key: 'expression',
|
||||
prompt: 'What do you want to answer?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, args) {
|
||||
const { expression } = args;
|
||||
try {
|
||||
const solved = math.eval(expression).toString();
|
||||
return msg.say(solved).catch(() => msg.say('Invalid Statement'));
|
||||
} catch (err) {
|
||||
return msg.say('Invalid Statement');
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user