mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
Add a debug mode that shows the error and the top of the stack trace in the case of an error if activated.
This commit is contained in:
parent
950ba882b8
commit
81217ece50
@ -13,5 +13,6 @@
|
||||
},
|
||||
"admins": [ "batman" ],
|
||||
"moduleNames": [ "ignore", "admin", "command", "dice", "js", "kick", "puns", "quotes", "spelling", "youare" ],
|
||||
"language": "english"
|
||||
"language": "english",
|
||||
"debugMode": true
|
||||
}
|
||||
|
@ -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 !== '~') {
|
||||
|
2
run.js
2
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user