mirror of
https://github.com/sern-handler/website
synced 2026-06-06 01:16:47 +00:00
1.5 KiB
1.5 KiB
sidebar_position
| sidebar_position |
|---|
| 5 |
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 :::
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
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.
await makeDependencies({
build: root => root.add({
eventlistener: single(() => new EventEmitter())
})
})
export default eventModule({
type: EventType.External,
emitter: 'eventlistener',
execute: (args) => {
console.log('Got event from eventlistener: ', args);
}
})