diff --git a/config.json.sample b/config.json.sample index 31c11f6..685eee6 100644 --- a/config.json.sample +++ b/config.json.sample @@ -13,5 +13,6 @@ }, "admins": [ "batman" ], "moduleNames": [ "ignore", "admin", "command", "dice", "js", "kick", "puns", "quotes", "spelling", "youare" ], - "language": "english" + "language": "english", + "debugMode": true } diff --git a/modules/command/command.js b/modules/command/command.js index 6342da2..ff530ff 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -79,7 +79,15 @@ var command = function(dbot) { } else { if(!isIgnoring(event.user, commandName)) { if(applyRegex(commandName, event)) { - dbot.commands[commandName](event); + try { + dbot.commands[commandName](event); + } catch(err) { + if(dbot.config.debugMode == true) { + event.reply('- Error in ' + commandName + ':'); + event.reply('- Message: ' + err); + event.reply('- Top of stack: ' + err.stack.split('\n')[1].trim()); + } + } dbot.save(); } else { if(commandName !== '~') { diff --git a/run.js b/run.js index e9e5132..187996d 100644 --- a/run.js +++ b/run.js @@ -5,7 +5,7 @@ require('./snippets'); var DBot = function(timers) { // Load external files - var requiredConfigKeys = [ 'name', 'servers', 'admins', 'moduleNames', 'language' ]; + var requiredConfigKeys = [ 'name', 'servers', 'admins', 'moduleNames', 'language', 'debugMode' ]; try { this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8')); } catch(err) {