I have the following code writing text depending on what message was sent to it:
var text = null;
try {
commandFiles.forEach((file) => {
if (text != null) {
return;
}
text = file.functionSwitch(event, command, commandArgs);
});
} catch(err) {
text = "I seem to have hit a problem. Please let bot creator look at it.";
const errChannel = client.channels.cache.find(channel => channel.id === errChannelID);
errChannel.send(err.message);
}
The code gives the following error:
TypeError: Cannot read property 'send' of undefined
I am not sure how to fix this error or properly find the channel. I have attempted with both get
and find
.
Thank you in advance.