Events Directory
CommandKit provides a special directory called events
inside the src/app
directory. This directory is used to define the events for your application. Each event is defined in its own file, and the file name should match the event name. For example, if you have an event called messageCreate
, you should create a file called messageCreate.ts
(or messageCreate.js
) in the src/app/events
directory.
| src/
| app/
| events/
| messageCreate/
| give-xp.ts
| log.ts
| ready/
| log.ts
| initialize.ts
CommandKit also supports using custom events in the events
directory. Custom events must be defined in a namespaced directory, which are handled by the active plugins. For example, if you have a custom event called guildMemberBoost
, you can create a file called src/app/events/(custom)/guildMemberBoost/handler.ts
which will be handled by the appropriate active plugins.
Event namespace directories are not same as category directories as they serve a different purpose.
You can use the custom events the same way as the built-in events. The only difference is that these events are namespaced and are handled by the plugins.