mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
32 lines
846 B
JavaScript
32 lines
846 B
JavaScript
const { Command } = require('discord.js-commando');
|
|
const math = require('mathjs');
|
|
|
|
module.exports = class MathCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: 'math',
|
|
group: 'random',
|
|
memberName: 'math',
|
|
description: 'Does math.',
|
|
args: [
|
|
{
|
|
key: 'expression',
|
|
prompt: 'What do you want to answer?',
|
|
type: 'string'
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
run(msg, args) {
|
|
const { expression } = args;
|
|
try {
|
|
const solved = math.eval(expression);
|
|
return msg.say(solved)
|
|
.catch(() => msg.say('Invalid statement.'));
|
|
} catch(err) {
|
|
return msg.say('Invalid statement.');
|
|
}
|
|
}
|
|
};
|