2023-12-17 14:55:27 -05:00
|
|
|
const CommandError = require('../CommandModules/command_error')
|
|
|
|
module.exports = {
|
|
|
|
name: 'calculator',
|
|
|
|
description:['calculate maths'],
|
2023-12-20 11:54:03 -05:00
|
|
|
trustLevel: 0,
|
2023-12-17 14:55:27 -05:00
|
|
|
aliases:['calc'],
|
|
|
|
execute (context) {
|
|
|
|
const bot = context.bot
|
|
|
|
const args = context.arguments
|
|
|
|
const cmd = {//test.js
|
|
|
|
translate: '[%s] ',
|
|
|
|
bold: false,
|
|
|
|
color: 'white',
|
|
|
|
with: [
|
|
|
|
{ color: 'blue', text: 'Calculator Cmd'},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
const operation = args[0]
|
|
|
|
const operator1 = parseFloat(args[1])
|
|
|
|
const operator2 = parseFloat(args[2])
|
|
|
|
|
|
|
|
//
|
|
|
|
switch (operation) {
|
|
|
|
case 'add':
|
|
|
|
context.source.sendFeedback({
|
|
|
|
translate: '[%s] %s is %s',
|
|
|
|
with: [
|
|
|
|
{color: 'blue', text:'Calculator Cmd'},
|
|
|
|
`${operator1} + ${operator2}`,
|
|
|
|
operator1 + operator2
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
break
|
|
|
|
case 'subtract':
|
|
|
|
context.source.sendFeedback({
|
|
|
|
translate: `[%s] %s is %s`,
|
|
|
|
with: [
|
|
|
|
{ color: 'blue', text: 'Calculator Cmd'},
|
|
|
|
`${operator1} - ${operator2}`,
|
|
|
|
operator1 - operator2
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
break
|
|
|
|
case 'multiply':
|
|
|
|
context.source.sendFeedback({
|
|
|
|
translate: '[%s] %s is %s',
|
|
|
|
with: [
|
|
|
|
{ color: 'blue', text: 'Calculator Cmd'},
|
|
|
|
`${operator1} x ${operator2}`,
|
|
|
|
operator1 * operator2
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
break
|
|
|
|
case 'divide':
|
|
|
|
context.source.sendFeedback({
|
|
|
|
translate: '[%s] %s is %s',
|
|
|
|
with: [
|
|
|
|
{ color: 'blue', text: 'Calculator Cmd'},
|
|
|
|
`${operator1} / ${operator2}`,
|
|
|
|
operator1 / operator2
|
|
|
|
]
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
context.source.sendError([cmd, { text: 'Invalid action', color: 'dark_red' }])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|