Getting Started
Listening to Events
This section is relevant only for gateway-based applications.
If your bot is built exclusively as an HTTP application, you can skip this section.
Updating Seyfert's Configuration
Before starting this section, you need to update the seyfert.config.mjs
file to specify the location of the event files for Seyfert.
Listening to Events
Each event file must export the createEvent
function as the default export so Seyfert can load it.
The createEvent
function takes an object with two properties: data
and run
.
Let's listen to the botReady
event as the first example:
As a second example, let's look at the guildDelete
event emitted by Discord when a bot is removed from a server or the server is deleted:
After completing these steps, your project structure should look like this:
src
commands
events
index.ts
package.json
seyfert.config.mjs
tsconfig.json
.env