Reputation: 82
I am trying to log all messages in a file for the bot on my server. However, whenever I run my bot and someone sends a message, I get this error:
UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
Here is my code:
if (message.channel.type !== 'dm')
{
var log = `[SERVER MESSAGE] ${message.member.user.tag}: "${message.content}" in #${message.channel.name}`;
console.log(log);
fs.writeFile("C:/Users/dubwi/Desktop/Discord_Bot/chatlog.json", `${log}`)
}
else{
message.reply("I don't accept DMs at the moment");
var log = `[DM MESSAGE] ${message.author.tag}: "${message.content}"`;
console.log(log);
fs.writeFile("C:/Users/dubwi/Desktop/Discord_Bot/chatlog.json", `${log}`)
}
Upvotes: 2
Views: 1357