discord-math

1.0.5 • Public • Published

Discord-Math

Discord-Math is a simple calculator for discord.js bots! It can both do math in commands, as well as to the console. This package is mainly used for discord.js math command in your bot!

Installing

Run npm i discord-math in a terminal!

Usage

Keep in mind that it can currently can only do 4 operations: +, -, *, /, **

Setup:

const math = require('discord-math');
 
module.exports = {
    name: "calculate",
    description: "The bot does math for you",
    run: async (client, message, args) => {
        try {
            let num1 = Number(args[0]);
            let operation = args[1];
            let num2 = Number(args[2]);
            
            if (!num1) return message.channel.send('Num1 needs to be specified!');
            if (!operation) return message.channel.send('An operation was not specified!');
            if (!num2) return message.channel.send('Num2 needs to be specified!');
 
            message.channel.send(`Answer: ${math.calculate(num1, operation, num2)}`);
        } catch (e) {
            console.log(e);
        }
    }
}

/discord-math/

    Package Sidebar

    Install

    npm i discord-math

    Weekly Downloads

    9

    Version

    1.0.5

    License

    ISC

    Unpacked Size

    2.08 kB

    Total Files

    4

    Last publish

    Collaborators

    • drait