2020-04-08 18:08:46 +02:00
|
|
|
const Component = require('./Component.js');
|
|
|
|
|
|
|
|
class Observer extends Component {
|
|
|
|
|
|
|
|
constructor(client, opts = {}) {
|
|
|
|
|
|
|
|
super(client, {
|
|
|
|
id: opts.name,
|
|
|
|
type: 'observer',
|
|
|
|
guarded: opts.guarded,
|
|
|
|
disabled: opts.disabled
|
|
|
|
});
|
|
|
|
|
2020-04-09 23:08:28 +02:00
|
|
|
this.client = client;
|
|
|
|
|
2020-04-08 18:08:46 +02:00
|
|
|
this.name = opts.name;
|
|
|
|
this.priority = opts.priority || 1;
|
|
|
|
this.hooks = opts.hooks || [];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
execute() {
|
|
|
|
return this._continue();
|
|
|
|
}
|
|
|
|
|
|
|
|
_continue() {
|
|
|
|
return { error: false, observer: this };
|
|
|
|
}
|
|
|
|
|
|
|
|
_stop() {
|
|
|
|
return { error: true, observer: this };
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Observer;
|