forked from Tricked-dev/discord-akairo
-
Notifications
You must be signed in to change notification settings - Fork 5
emitters
IRONM00N edited this page Oct 11, 2021
·
1 revision
As shown in the first listener tutorial, we can have custom emitters.
Listeners can run on more than Akairo-related things.
To add a custom emitter, use the setEmitters
method available on the listener handler.
this.listenerHandler.setEmitters({
process: process,
anything: youWant
});
Note: You have to call setEmitters
before load
or loadAll
so that Akairo will be able to resolve your emitters.
The key will be the emitter's name, and the value is the emitter itself.
Now, we can use a listener on the process:
import { Listener } from "discord-akairo";
export default class UnhandledRejectionListener extends Listener {
constructor() {
super("unhandledRejection", {
event: "unhandledRejection",
emitter: "process"
});
}
exec(error: Error): void {
console.error(error);
}
}