galactic-bot/structure/client/Dispatcher.js

25 lines
516 B
JavaScript
Raw Normal View History

2020-04-08 18:08:46 +02:00
class Dispatcher {
constructor(client) {
this.client = client;
}
async dispatch() {
const observers = this.client.registry.components
.filter((c) => c.type === 'observer' && !c.disabled)
2020-04-08 18:08:46 +02:00
.sort((a, b) => b.priority - a.priority);
for(const observer of observers.values()) {
for(const [hook, func] of observer.hooks) {
this.client.eventHooker.hook(hook, func);
2020-04-08 18:08:46 +02:00
}
}
}
}
module.exports = Dispatcher;