easy-mathematics
v1.0.1
Published
A simple, easy, ultra light evaluator for mathematical calculations
Downloads
1
Readme
math-evaluator
Easy, safe, ultra light
Mostly Made for discord.js but you can use for other's too!
Usage
//Discord.js
const eval = require("math-evaluator");
const Discord = require('discord.js');
const bot = new Discord.Client();
const prefix = '-' //you can use any prefix you like :)
bot.on('ready', async () => console.log('Ready'));
bot.on('message', async message => {
let messageArray = message.content.split(' ');
let args = messageAray.slice(1);
if(message.content.startsWith(`${prefix}evaluate`)) {
let toEval = args.join(' ');
let result = await eval(toEval);
message.channel.send(result);
}
})
// Asynchronous function
(async () => {
let result = await eval('1+1')
.catch(e => console.log(e));
console.log(result);
})();
// Synchronous function
(() => {
let result = eval('1+1')
.then(r => console.log(r))
.catch(e => console.log(e));
})();