Skip to content
This repository has been archived by the owner on Aug 28, 2020. It is now read-only.

Commit

Permalink
Make monitors safe, add monitorError event
Browse files Browse the repository at this point in the history
  • Loading branch information
AoDude committed Nov 29, 2017
1 parent 535f7b8 commit f7d0ebe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/lib/structures/MonitorStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

Expand Down

0 comments on commit f7d0ebe

Please # to comment.