mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 14:04:38 +02:00
args and more
This commit is contained in:
@@ -14,22 +14,24 @@ module.exports = class MathCommand extends commando.Command {
|
||||
group: 'numedit',
|
||||
memberName: 'math',
|
||||
description: 'Does Math (;math 2 + 2)',
|
||||
examples: [';math 2 + 2']
|
||||
examples: [';math 2 + 2'],
|
||||
args: [{
|
||||
key: 'expression',
|
||||
prompt: 'What do you want to answer?',
|
||||
type: 'string'
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
run(message) {
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let expression = message.content.split(" ").slice(1).join(" ");
|
||||
let expression = args.expression;
|
||||
try {
|
||||
let solved = math.eval(expression);
|
||||
return message.channel.send(solved).catch(err => {
|
||||
console.log(err);
|
||||
message.channel.send(":x: Error! Invalid statement!");
|
||||
});
|
||||
return message.channel.send(solved).catch(err => message.channel.send(":x: Error! Invalid statement!"));
|
||||
}
|
||||
catch (err) {
|
||||
return message.channel.send(":x: Error! Invalid statement!");
|
||||
|
||||
Reference in New Issue
Block a user