Events are placed in ./events/
. If a conflicting event is present in both the core and your client, only your client version is loaded and will run when that event is triggered.
Their structure is the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
const { Event } = require('klasa');
module.exports = class extends Event {
constructor(...args) {
super(...args, { name:'yourEventName', enabled: true });
}
run(...params) {
// This is where you place the code you want to run for your event
}
async init() {
// You can optionally define this method which will be run when the bot starts (after login, so discord data is available via this.client)
}
};
Where ...params
are arguments you would normally get from those events. For example, while the ready
event would only have none, the guildMemberAdd
event would be member
.
Configuration
Name | Default | Type | Description |
---|---|---|---|
name | theFileName |
string | The name of the event |
enabled | true |
boolean | Whether the event is enabled or not |