diff --git a/src/lib/Client.js b/src/lib/Client.js index af02e866f9..7ef8c34c38 100644 --- a/src/lib/Client.js +++ b/src/lib/Client.js @@ -505,6 +505,15 @@ KlasaClient.defaultPermissionLevels = new PermLevels() * @param {(string|Object)} error The command error */ +/** + * Emitted when a monitor has errored. + * @event KlasaClient#monitorError + * @since 0.4.0 + * @param {external:Message} message The message that triggered the monitor + * @param {Monitor} monitor The monitor run + * @param {(string|Object)} error The monitor error + */ + /** * Emitted when {@link SettingGateway.update}, {@link SettingGateway.updateArray} or {@link SettingGateway.reset} is run. * @event KlasaClient#settingUpdate diff --git a/src/lib/structures/MonitorStore.js b/src/lib/structures/MonitorStore.js index ef51f0146d..32264ef195 100644 --- a/src/lib/structures/MonitorStore.js +++ b/src/lib/structures/MonitorStore.js @@ -76,7 +76,9 @@ class MonitorStore extends Collection { */ run(msg) { for (const monit of this.values()) { - if (monit.enabled && !(monit.ignoreBots && msg.author.bot) && !(monit.ignoreSelf && this.client.user === msg.author) && !(monit.ignoreOthers && this.client.user !== msg.author)) monit.run(msg); + if (monit.enabled && !(monit.ignoreBots && msg.author.bot) && !(monit.ignoreSelf && this.client.user === msg.author) && !(monit.ignoreOthers && this.client.user !== msg.author)) { + monit.run(msg).catch(err => this.client.emit('monitorError', msg, monit, err)); + } } }