{"size": 1224, "ext": "js", "max_stars_repo_path": "SlashCommands/Utility/math.js", "max_stars_repo_name": "ultratrikx/AlphaBot", "max_stars_repo_stars_event_min_datetime": "2021-04-26T20:00:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-07T15:19:30.000Z", "max_issues_repo_path": "SlashCommands/Utility/math.js", "max_issues_repo_name": "ultratrikx/AlphaBot", "max_issues_repo_issues_event_min_datetime": "2021-06-20T16:43:09.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-20T17:26:26.000Z", "max_forks_repo_path": "SlashCommands/Utility/math.js", "max_forks_repo_name": "ultratrikx/AlphaBot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 31.3846153846, "max_line_length": 82, "alphanum_fraction": 0.5383986928}
const { Client, CommandInteraction, MessageEmbed } = require("discord.js");
const { SlashCommandBuilder } = require('@discordjs/builders')
module.exports = {
    ...new SlashCommandBuilder()
        .setName('math')
        .setDescription('solves math equations')
        .addStringOption(option => 
            option
                .setName('equation')
                .setDescription('the equation you want to solve')
                .setRequired(true)
        ),

    /**
     *
     * @param {Client} client
     * @param {CommandInteraction} interaction
     * @param {String[]} args
     */
    run: async (client, interaction, args) => {
        const equation = interaction.options.getString('equation');

        let resp;

        try {
            resp = math.evaluate(equation.join(' '));
        } catch (e) {
            return interaction.followUp({ content: `a **valid** equation please`})
        }

        const embed = new MessageEmbed()
            .setColor(0x808080)
            .setTitle('Big Brain')
            .addField('Qustion', `\`\`\`css\n${equation.join(' ')}\`\`\``)
            .addField('Answer', `\`\`\`css\n${resp}\`\`\``);

        interaction.followUp({ embeds: [embed]});
    },
};