Listening for Events
In this section you will learn how to listen for events with the Event
abstract class from the Guilded.TS framework. Lets start by creating a folder named events
in the root directory, this will be used to store your events. After you have made a events
directory, create a file named ready.{js,ts}
inside it, this will be your ready event listener. Inside the file, add the following:
import Client, { Event } from '@guildedts/framework';
export default class extends Event {
execute(client: Client) {
console.log(`Logged in as ${client.user?.name}`);
}
}
const { Event } = require('@guildedts/framework');
module.exports = class extends Event {
execute(client) {
console.log(`Logged in as ${client.user?.name}`);
}
}
import { Event } from '@guildedts/framework';
export default class extends Event {
execute(client) {
console.log(`Logged in as ${client.user?.name}`);
}
}
Examples
TIP
By default, the event name is the name of the file without the extension. For example, ready.js
is ready
.