complete error catching

This commit is contained in:
2021-08-23 17:07:39 +02:00
parent 3dedfaca25
commit 7659d97665

View File

@@ -18,7 +18,6 @@ for (const Fl of cmdsFls) {
} }
cl.on('messageCreate', (msg) => { cl.on('messageCreate', (msg) => {
console.log('a message has been received');
if (!msg.content.startsWith(cfg.prefix) || msg.author.bot) return; if (!msg.content.startsWith(cfg.prefix) || msg.author.bot) return;
const args = msg.content.slice(cfg.prefix.length).trim().split(/ +/); const args = msg.content.slice(cfg.prefix.length).trim().split(/ +/);
@@ -30,9 +29,13 @@ cl.on('messageCreate', (msg) => {
try { try {
cmd.execute(msg); cmd.execute(msg);
} catch (error) { } catch (error) {
console.error(error); console.error(
message.reply(`the above error occured while trying to execute ${cmd}`); `msgCommand error: ${cmdName} by ${msg.author.tag}\n--\n${error}\n--`
);
msg.reply(`An error occured while trying to execute ${cmdName}`);
return;
} }
console.log(`msgCommand: ${cmdName} by ${msg.author.tag}`);
}); });
cl.once('ready', () => { cl.once('ready', () => {