First Event Module
We will dissect a basic event module.
tip
TLDR: event modules are event listeners. there are three types EventType.Discord, EventType.Sern, EventType.External
- JavaScript
- Typescript
exports.default = eventModule({
type: EventType.Sern,
plugins : [],
name: 'module.activate',
execute(event) {
console.log(event);
}
})
export default eventModule({
type: EventType.Sern,
plugins : [],
name: 'module.activate', //name of event.
execute(event) {
console.log(event);
}
})
Like command modules, the type
property denotes what kind of event it is, which
can be found here.
To view what each of these properties mean in depth, visit the official documentation.
External
In version 2 & 3, any dependency that you have passed into makeDependencies can be registered here as well.
src/index.ts
await makeDependencies({
build: root => root.add({
eventlistener: single(() => new EventEmitter())
})
})
events/myevent.ts
export default eventModule({
type: EventType.External,
emitter: 'eventlistener',
execute: (args) => {
console.log('Got event from eventlistener: ', args);
}
})