İçeriğe geç
sern

First Event

Bu içerik henüz dilinizde mevcut değil.

Introduction

In this guide, we’ll walk you through creating your first event module.

src/events/activate.js
1
exports.default = eventModule({
2
type: EventType.Sern,
3
plugins : [],
4
name: 'module.activate',
5
execute(event) {
6
console.log(event);
7
}
8
})

Similar to command modules, the type property denotes what kind of event it is. You can view EventType for more information.

To view what each of these properties mean in depth, visit the docs for EventType.

External Events

In versions 2 & 3, any dependency that you have passed into makeDependencies can be registered here as well.

src/index.ts
1
await makeDependencies({
2
build: root => root.add({
3
eventlistener: single(() => new EventEmitter())
4
})
5
})

In your event module, you can now listen to events from eventlistener, which will be emitted from the EventEmitter.

src/events/myevent.ts
1
export default eventModule({
2
type: EventType.External,
3
emitter: 'eventlistener',
4
execute: (args) => {
5
console.log('Got event from eventlistener: ', args);
6
}
7
})