galactic-bot/structure/client/Dispatcher.js
2020-06-20 00:01:58 +03:00

25 lines
516 B
JavaScript

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