So I'm trying to make a bot that does quick math for me via commands. My prefix is da$h
and the command is payment. When I try the command da$h payment 1 + 1
for example, I'm presented with the same error every time. I'm using mathjs
node btw.
I've tried putting await before send functions and async in front of all the return functions but I get the same exact error.
const math = require('mathjs');
const Discord = require('discord.js');
exports.run = (client, message, args, tools) => {
if (!args[0]) return message.channel.send('Please input a calculation,');
let resp;
try {
resp = math.evaluate(args.join(' '));
} catch (e) {
return message.channel.send('Sorry, please input a valid calculation');
}
const embed = new Discord.RichEmbed()
.setColor(0xffffff)
.setTitle('Math Calculation')
.addField('Input', `\`\`\`${args.join(' ')}\`\`\``)
.addField('Output', `\`\`\`js${resp}\`\`\``)
message.channel.send(embed);
}
Here's the error I keep getting:
node:18876) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message at item.request.gen.end (C:\Users\Admin\Desktop\coding\node_modules\Discord.js\src\client\rest\RequestHandlers\Sequential.js:71:65) at then (C:\Users\Admin\Desktop\coding\node_modules\snekfetch\src\index.js:204:21) at process._tickCallback (internal/process/next_tick.js:68:7) (node:18876) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:18876) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.