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