try {
await handleBotResponse(message, contentWithoutMention); // Moved bot response handling here
} catch (error) {
console.error('Error:', error);
if (error.response && error.response.status === 403) {
// Handle Missing Permissions error (code 50013) by logging without stopping the bot
console.error('Bot is missing permissions in this channel');
message.channel.send('Sorry, I don\'t have the necessary permissions to respond in this channel.');
} else {
// Log other errors and inform the user
console.error('Unhandled error occurred:', error);
message.channel.send('Sorry, I encountered an error while processing your request.');
}
}
}
} catch (outerError) {
console.error('Unhandled exception in messageCreate event handler:', outerError);
}
try {
await handleBotResponse(message, contentWithoutMention); // Moved bot response handling here
} catch (error) {
console.error('Error:', error);
if (error.response && error.response.status === 403) {
// Handle Missing Permissions error (code 50013) by logging without stopping the bot
console.error('Bot is missing permissions in this channel');
message.channel.send('Sorry, I don\'t have the necessary permissions to respond in this channel.');
} else {
// Log other errors and inform the user
console.error('Unhandled error occurred:', error);
message.channel.send('Sorry, I encountered an error while processing your request.');
}
}
}
} catch (outerError) {
console.error('Unhandled exception in messageCreate event handler:', outerError);
}