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