mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-22 03:15:41 +01:00
Added try catch blocks so script execution does not halt.
This commit is contained in:
parent
e2ee403ee2
commit
f9896bdd15
@ -73,16 +73,20 @@ client.on('message', message => {
|
||||
logger.info(`${message.author.username} ${message.author} [Channel: ${message.channel}] triggered command: ${message.content}`);
|
||||
message.delete();
|
||||
|
||||
try {
|
||||
if (cachedModuleType == 'Command') {
|
||||
cachedModule.command(message);
|
||||
} else if (cachedModuleType == 'Quote') {
|
||||
cachedModules['quote.js'].command(message, cachedModule.reply);
|
||||
}
|
||||
} catch (err) { logger.error(err); }
|
||||
|
||||
try {
|
||||
// Check if the command requires a warning.
|
||||
if (cmd != 'warn' && cachedModule.warn == true) {
|
||||
cachedModules['warn.js'].command(message);
|
||||
}
|
||||
} catch (err) { logger.error(err); }
|
||||
} else {
|
||||
// Not a valid command.
|
||||
}
|
||||
@ -91,7 +95,9 @@ client.on('message', message => {
|
||||
cachedTriggers.forEach(function(trigger) {
|
||||
if (trigger.roles == undefined || findArray(message.member.roles.map(function(x) { return x.name; }), trigger.roles)) {
|
||||
if (trigger.trigger(message) == true) {
|
||||
try {
|
||||
trigger.execute(message);
|
||||
} catch (err) { logger.error(err); }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user